1. 程式人生 > >Struts2 ui標簽

Struts2 ui標簽

標簽 自己 val blog pro ext word com class

命名空間:在form action=”命名空間名/action”

struts2 ui標簽庫

引包: <[email protected] uri="/struts-tags"prefix="s" %>  

<[email protected] uri="/struts-tags"prefix="s" %>
   <s:form action="login"method="post" name="frm"id="frm" theme="xhtml">
 
         <s:textfield name="user.uname"label="username"></s:textfield>
         <s:password name="user.pwd"label="password"></s:password>
         <s:radio list="{‘男生‘,‘女生‘,‘男人‘,‘女人‘,‘男子‘,‘女子‘}" name="sex"label="性別"></s:radio>
         <s:checkboxlist list="{‘vrey‘,‘good‘,‘bad‘,‘壞‘,‘孬‘,‘好‘}" name="hobby" label="愛好"></s:checkboxlist>
         <s:select list="{‘北京‘,‘南京‘,‘東京‘}" name="city" label="城市"></s:select>
         <s:textarea rows="5"clos="20" name="info"label="自己介紹"></s:textarea>
         <s:submit label="登陸"></s:submit>
     </s:form>
 
       ognl:
<s:property value="#application.user.pwd"/>

struts.xml通配符使用:

struts.xml:

<action name="user_*"class="com.bjsxt.action.LoginAction" method="{1}">

<result name="{1}">/ognl.jsp</result>

</action>

.jsp:

<form action="user_zzu">

<input type="submit"

value="zzu">

</form>

.java:

public String zzu() {

user.setUname("zzdx");

user.setPwd("yyuy");

return "zzu";

}

Struts2 ui標簽