zoukankan      html  css  js  c++  java
  • velocity入门

    http://wenku.baidu.com/view/b401add728ea81c758f57882.html?re=view

     1 package cn.edu;
     2 
     3 import java.io.File;
     4 import java.io.FileOutputStream;
     5 import java.io.PrintWriter;
     6 import java.io.Writer;
     7 
     8 import org.apache.velocity.Template;
     9 import org.apache.velocity.VelocityContext;
    10 import org.apache.velocity.app.Velocity;
    11 import org.apache.velocity.app.VelocityEngine;
    12 //http://wenku.baidu.com/view/b401add728ea81c758f57882.html?re=view
    13 public class VelocityTest {
    14 
    15     public static void main(String[] args) throws Exception{
    16         VelocityEngine ve=new VelocityEngine();
    17         String path="D:/workspace/velocityPro/HelloVelocity/src/cn/edu/";
    18         ve.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
    19         
    20         ve.setProperty(Velocity.INPUT_ENCODING, "GBK");
    21         ve.setProperty(Velocity.OUTPUT_ENCODING, "GBK");
    22         
    23         ve.init();
    24         
    25         Template template =ve.getTemplate("hello.html");
    26         
    27         VelocityContext root=new VelocityContext();
    28         
    29         root.put("name", "valueadfasdf");
    30         String outpath="e:/helloworld.html";
    31         Writer mywriter= new PrintWriter(new FileOutputStream(new File(outpath)));
    32         template.merge(root, mywriter);
    33         mywriter.flush();
    34         
    35     }
    36     
    37 }
    View Code
  • 相关阅读:
    用react+redux+webpack搭建项目一些疑惑
    ajax基本原理实现
    jsonp详细原理之一
    因为文件共享不安全,所以你不能连接到文件共享
    python xml模块
    python os模块
    python tickle模块与json模块
    python datetime模块
    python sys模块
    python time模块
  • 原文地址:https://www.cnblogs.com/friends-wf/p/3821624.html
Copyright © 2011-2022 走看看