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

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

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

    我的漫漫程序之旅

    專注于JavaWeb開發
    隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
    數據加載中……

    Struts2屬性文件簡單應用

    在包下建立名為pageckage.properties的文件.我這里的包是com.內容如下:
    requiredstring = $\{getText(fieldName)} is required.
    password = Password
    username = User Name

    這里我們需要改一下我們的LoginAction-validation.xml:

     

     <message>Username is required</message>
     
    <message key="requiredstring"/> 

     
    <message>Password is required</message>
     
    <message key="requiredstring"/> 

    紅色-號標志的為原先內容,+號內容為現在修改后的內容.

    login.jsp:

    <%@ page language="java" pageEncoding="GB18030"%>
    <%@taglib prefix="s" uri="/struts-tags"%>
    <html>
     
    <head>
      
    <title>My JSP 'login' starting page</title>
     
    </head> 

     
    <body>
      
    <s:form action="login" method="post">
       
    <s:textfield name="username" label="%{getText('username')}" />
       
    <br />
       
    <s:textfield name="password" label="%{getText('password')}" />
       
    <br />
       
    <s:submit />
      
    </s:form>
     
    </body>
    </html>

    struts.xml文件:

    <struts>
     
    <package name="com" extends="struts-default">
      
    <action name="*" class="com.LoginAction">
          
    <result name="input">/login.jsp</result>
       
    <result>/success.jsp</result>
      
    </action>
     
    </package>
    </struts>    

    LoginAction文件:

    package com; 

    import com.opensymphony.xwork2.ActionSupport; 

    public class LoginAction extends ActionSupport


     
    private static final long serialVersionUID = 4771028725069625041L;
     
     
    private String username;
     
    private String password;
     
    public String getUsername()
     
    {
      
    return username;
     }

     
    public void setUsername(String username)
     
    {
      
    this.username = username;
     }

     
    public String getPassword()
     
    {
      
    return password;
     }

     
    public void setPassword(String password)
     
    {
      
    this.password = password;
     }

     @Override
     
    public String execute()
     
    {
      System.out.println(getText(
    "username"+ ":" + username);
      System.out.println(getText(
    "password"+ ":" + password);
      
    return SUCCESS;
     }

    }


    properties文件的內容按以下順序檢索:

    Resource bundles are searched in the following order:

    1. ActionClass.properties
    2. BaseClass.properties (all the way to Object.properties)
    3. Interface.properties (every interface and sub-interface)
    4. ModelDriven's model (if implements ModelDriven), for the model object repeat from 1
    5. package.properties (of the directory where class is located and every parent directory all the way to the root directory)
    6. search up the i18n message key hierarchy itself
    7. global resource properties

    源碼請在我的網盤下



    posted on 2007-11-24 07:29 々上善若水々 閱讀(1210) 評論(0)  編輯  收藏 所屬分類: Struts2

    主站蜘蛛池模板: 亚洲A∨精品一区二区三区下载| 亚洲图片中文字幕| 精品在线免费视频| 拔擦拔擦8x华人免费久久| 亚洲色大情网站www| 好爽…又高潮了毛片免费看 | a级片免费观看视频| 精品国产香蕉伊思人在线在线亚洲一区二区 | 国产三级免费电影| 精品成人一区二区三区免费视频| 国产大片51精品免费观看| 国产精品久久久久久亚洲小说| 国产免费爽爽视频免费可以看| 羞羞的视频在线免费观看| 国产av无码专区亚洲国产精品| 三年片免费高清版 | 成人毛片免费观看视频大全| 亚洲人av高清无码| 波多野结衣免费视频观看| 亚洲日韩在线观看免费视频| 亚洲乱码国产乱码精品精| 日韩精品人妻系列无码专区免费 | 无码专区AAAAAA免费视频| 亚洲国产品综合人成综合网站| 最近最新MV在线观看免费高清| 精品久久久久久久久亚洲偷窥女厕| 亚洲Av无码国产情品久久 | 亚洲爆乳AAA无码专区| 亚洲av日韩av欧v在线天堂| 91免费在线视频| 亚洲乱码中文字幕小综合| 国产18禁黄网站免费观看| 两个人看的www视频免费完整版| 麻豆亚洲AV永久无码精品久久| 毛片免费全部播放一级| 日本激情猛烈在线看免费观看| 亚洲国产精品自在线一区二区| 日本人护士免费xxxx视频| 国产色爽免费无码视频| 亚洲日韩AV一区二区三区中文 | 成全在线观看免费观看大全 |