锘??xml version="1.0" encoding="utf-8" standalone="yes"?>中文字幕av在线,欧美成aaa人片在线观看蜜臀,一级欧美视频http://www.aygfsteel.com/dingdangxiaoma/category/30825.htmlzh-cnTue, 15 Apr 2008 08:34:02 GMTTue, 15 Apr 2008 08:34:02 GMT60velocity 渚嬪瓙http://www.aygfsteel.com/dingdangxiaoma/articles/193098.html鍙綋灝忛┈鍙綋灝忛┈Tue, 15 Apr 2008 07:01:00 GMThttp://www.aygfsteel.com/dingdangxiaoma/articles/193098.htmlhttp://www.aygfsteel.com/dingdangxiaoma/comments/193098.htmlhttp://www.aygfsteel.com/dingdangxiaoma/articles/193098.html#Feedback1http://www.aygfsteel.com/dingdangxiaoma/comments/commentRss/193098.htmlhttp://www.aygfsteel.com/dingdangxiaoma/services/trackbacks/193098.html 鍩虹鎼緩錛氫粠緗戜笂涓嬭澆velocity.zip錛屾妸lib涓嬬殑.jar鏂囦歡瀵煎叆鍒板伐紼嬩腑銆傚彟澶栬繕瑕佸鍏elocity.jar 鍜寁elocity-dep.jar.
hellosite.vm  鏀懼埌宸ョ▼鐨勭洰褰曞簳涓嬨?br />
Hello $name! Welcome to $site world!
HelloWorld.java
package com;
import java.io.StringWriter;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
public class HelloWorld {
    
public static void main(String[] args) throws Exception {
        
/* first, get and initialize an engine */
        VelocityEngine ve 
= new VelocityEngine();
        ve.init();
        
/* next, get the Template */
        Template t 
= ve.getTemplate("hellosite.vm");
        
/* create a context and add data */
        VelocityContext context 
= new VelocityContext();
        context.put(
"name""DingDangXiaoMa");
        context.put(
"site""http://www.sun.com");
        
/* now render the template into a StringWriter */
        StringWriter writer 
= new StringWriter();
        t.merge(context, writer);
        
/* show the World */
        System.out.println(writer.toString());
    }
}
鐩存帴榪愯榪欎釜紼嬪簭錛屽氨鍙互杈撳叆妯℃澘涓殑淇℃伅銆?br /> 2銆倃eb紼嬪簭錛宻ervlet 璋冪敤vm鏄劇ず淇℃伅銆?br /> hello.vm 鏀懼湪webRoot/web/涓嬨?br />
<html>
    
<body >        
     #set($name
="Hello ! DingDang")
        Hello, $name 
        woowoo
    
</body>
</html>
servlet 鏂囦歡錛?br />
public class SampleServlet extends VelocityServlet {
    
protected Properties loadConfiguration(ServletConfig config)
            
throws IOException, FileNotFoundException {
        Properties p 
= new Properties();
        String path 
= config.getServletContext().getRealPath("/");
        
if (path == null) {
            System.out
                    .println(
" SampleServlet.loadConfiguration() : unable to "
                            
+ "get the current webapp root.  Using '/'. Please fix.");
            path 
= "/";
        }
        p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
        p.setProperty(
"runtime.log", path + "velocity.log");
        
return p;
    }
    
public Template handleRequest(HttpServletRequest request,
            HttpServletResponse response, Context ctx) {
        
/**
         * 鎴戠殑涓浜涙祴璇曡緭鍑?br />          
*/
        System.out.println(
"Hello  everyone");
        System.out.println(
"sfdsfsd");
        System.out.println(ctx);
        System.out.println(ctx.toString());
        System.out.println(request.getContextPath());
        Template template 
= null;

        
try {
            
/**
             * 涓昏浠g爜
             
*/
            Velocity.init();
            
/**
             * 娉ㄦ剰鐩稿璺緞
             
*/
            template 
= Velocity.getTemplate("/web/hello.vm");
            VelocityContext context 
= new VelocityContext();
            context.put(
"name""wowowowowowo  hello   hello  hello");
            
// template = Velocity.getTemplate("/web/sample.html");
        } catch (Exception e) {
            e.printStackTrace();
        }
        
return template;
    }
}
浠ヤ笂灝辨槸涓や釜鏈綆鍗曠殑velocity鐨勪緥瀛愩?涓涓槸java application 涓涓槸java web紼嬪簭銆?br /> 鍙傝冭祫鏂欙細
http://www.javaresearch.org/article/38895.htm


]]>
主站蜘蛛池模板: 普安县| 瑞丽市| 安平县| 岳西县| 清河县| 开平市| 环江| 新民市| 东至县| 江陵县| 花垣县| 平乐县| 鹤峰县| 古浪县| 龙里县| 綦江县| 嘉兴市| 冀州市| 大理市| 商丘市| 固阳县| 铜川市| 马鞍山市| 教育| 田东县| 仪征市| 若羌县| 无为县| 荔浦县| 巴中市| 昌平区| 丹东市| 舟山市| 南木林县| 岢岚县| 邳州市| 浦江县| 云霄县| 祁门县| 正蓝旗| 曲阳县|