<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    躺在沙灘上的小豬

    快樂的每一天

    #

    Acegi+hibernate 動態實現基于角色的權限管理

    http://www.tkk7.com/limq/archive/2006/01/19/28585.html

    posted @ 2006-01-19 16:52 martin xus| 編輯 收藏

    wiki語法

         摘要: 喜歡 Confluence 最主要的原因其實是因為我喜歡他強大的wiki語法,今天閑的無事,試著用javascript寫了看看: <html><head>    <title>Demo</title>    <link rel="stylesheet"&...  閱讀全文

    posted @ 2006-01-18 20:21 martin xus| 編輯 收藏

    FreeMarker Quick Start


    和所有的介紹一樣,我們以Hello World開始,在以后所有的例子中,我們采用webwork/xwork作為Controller.

    package cn.martin.freemarker.quickstart.action;

    import com.opensymphony.xwork.ActionSupport;

    /**
     * 
    @author martin
     
    */

    public class HelloAction extends ActionSupport {
        
    private String message;

        
    public String getMessage() {
            
    return message;
        }


        
    public String execute() throws Exception {
            
    this.message ="Hello World!";
            
    return SUCCESS;
        }

    }

    我們的頁面很簡單,只是顯示message
    <html>
    <head>
        
    <title>FreeMarker Quick Start</title>
    </head>

    <body>

    ${message}

    </body>
    </html>
    • ${message}:稱為interpolations,FreeMarker會在輸出時用實際值進行替代,它會按以下的順序查找message變量
      • The value stack
      • The action context
      • Request scope
      • Session scope
      • Application scope
      • Built-in variables

    如果沒有該變量,會拋出異常。

    其他還有

    • FTL標記(FreeMarker模板語言標記):以<#開頭,我們會在下面用到
    • 注釋:包含在<#-->之間

    配置xwork.xml

    <!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"
            "http://www.opensymphony.com/xwork/xwork-1.0.dtd"
    >

    <xwork>
        
    <include file="webwork-default.xml"/>

        
    <package name="default" extends="webwork-default">
            
    <action name="demo"
                    class
    ="cn.martin.freemarker.quickstart.action.HelloAction">
                
    <result name="success" type="freemarker">/templates/demo.ftl</result>
            
    </action>
        
    </package>
    </xwork>

    webwork.properties
    # extension for actions
    webwork.action.extension=

    # spring integration
    #
    webwork.objectFactory=spring
    #
    webwork.objectFactory.spring.autoWire=type

    ### Configuration reloading
    #
     This will cause the configuration to reload xwork.xml when it is changed
    webwork.configuration.xml.reload=true

    ### Load custom default resource bundles
    webwork.custom.i18n.resources=default

    ### character encoding
    webwork.i18n.encoding=UTF-8
    1. 暫時我們用不到spring,沒有必要引人
    2. 至于后綴,個人愛好,我不喜歡那么多的東西,沒有任何后綴.

    工程整體結構如下:

    web.xml

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
            "http://java.sun.com/dtd/web-app_2_3.dtd"
    >
    <web-app>
        
    <filter>
            
    <filter-name>webwork</filter-name>
            
    <filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
        
    </filter>

        
    <filter-mapping>
            
    <filter-name>webwork</filter-name>
            
    <url-pattern>/*</url-pattern>
        
    </filter-mapping>

        
    <welcome-file-list>
            
    <welcome-file>index.html</welcome-file>
            
    <welcome-file>demo.action</welcome-file>
        
    </welcome-file-list>
        
    <taglib>
            
    <taglib-uri>webwork</taglib-uri>
            
    <taglib-location>/WEB-INF/lib/webwork.jar</taglib-location>
        
    </taglib>
    </web-app>

    OK!deploy到server看一下結果:

    Next:繼續前進

    我們來將頁面做的更友好一些,用戶輸入姓名,顯示Hello + 用戶名

    <html>
    <head>
        
    <title>FreeMarker Quick Start</title>
    </head>

    <body>

    <#if userName?exists&&userName?has_content>
           Hello ${userName}!
    </#if>


    <form action="demo" method="post">
        Input your name:
    <input type="text" size="8" name="userName"/>
        
    <input type="submit" value="Get Words"/>
    </form>

    </body>
    </html>

    在該頁面中,我們見到一些奇怪的表達式
    <#if userName?exists&&userName?has_content>
           Hello $
    {userName}!
    </#if>

    這是FreeMarker的表達式,暫時不管它,先了解一下即可,以后會有專門的介紹.

    1. userName?exists 判斷該變量是否存在
    2. userName?has_content 判斷該變量是否不為null并且不為empty

    修改Action

    package cn.martin.freemarker.quickstart.action;

    import com.opensymphony.xwork.ActionSupport;

    /**
     * 
    @author martin
     
    */

    public class HelloAction extends ActionSupport {
        
    private String userName;

        
    public void setUserName(String userName) {
            
    this.userName = userName;
        }


        
    public String getUserName() {
            
    return userName;
        }


        
    public String execute() throws Exception {
            System.out.println(
    "HelloAction.execute() begin");
            
    return SUCCESS;
        }

    }

    結果如下:

    代碼:freemarker.rar 去掉了webwork/xwork/freemarker lib,請自行添上。

    參考:
    xwork:http://www.opensymphony.com/xwork
    webwork:http://www.opensymphony.com/
    freemarker:http://freemarker.org/

    posted @ 2006-01-17 19:12 martin xus| 編輯 收藏

    Python 新站點

    http://beta.python.org/

    好漂亮!

    posted @ 2006-01-12 14:00 martin xus| 編輯 收藏

    Windows Live Messenger Beta 邀請

    http://ideas.live.com/

    Windows Live Messenger Beta 邀請,需要的留msn



     

    posted @ 2006-01-12 09:00 martin xus| 編輯 收藏

    僅列出標題
    共28頁: First 上一頁 10 11 12 13 14 15 16 17 18 下一頁 Last 
    主站蜘蛛池模板: 亚洲精品乱码久久久久久久久久久久| 国产一精品一aⅴ一免费| 久99精品视频在线观看婷亚洲片国产一区一级在线 | 亚洲AV永久无码区成人网站| 九九热久久免费视频| 亚洲中文久久精品无码| 三级网站免费观看| 亚洲AV永久无码精品一百度影院| a级日本高清免费看| 亚洲av无码成h人动漫无遮挡| 久久久久免费看黄a级试看| 91精品国产亚洲爽啪在线影院| 99re免费在线视频| 99999久久久久久亚洲| 最近最好的中文字幕2019免费| 亚洲欧美乱色情图片| 特级淫片国产免费高清视频| 美女视频免费看一区二区| 亚洲乱亚洲乱少妇无码| 免费观看成人久久网免费观看| 亚洲一区二区影院| 毛片基地免费视频a| 成人国产网站v片免费观看 | 日木av无码专区亚洲av毛片| 国产麻豆视频免费观看| 黄网站在线播放视频免费观看| 国产亚洲老熟女视频| 91av免费观看| 国产亚洲综合久久| 亚洲AV成人片色在线观看| 男人的好看免费观看在线视频| 人与动性xxxxx免费| 91亚洲自偷手机在线观看| 日韩视频在线免费| 最新亚洲成av人免费看| 亚洲卡一卡二卡乱码新区| 亚洲精品国产精品乱码不卞| 亚洲第一网站免费视频| 成人国产网站v片免费观看| 亚洲国产成人精品青青草原| 亚洲A∨精品一区二区三区|