Struts2控件的使用以及取值後回顯

zhuce.jsp
jsp

<body>ide

<fieldset>post

<legend>註冊</legend>spa

<s:form action="addtags.action" method="post">orm

<s:textfield name="username" value="ql" label="用戶名"></s:textfield>xml

<s:radio list="#{'0':'男','1':'女','3':'待定'}" name="sex" value="0" label="性別" ></s:radio>get

<s:select list="#{'cc':'長春','bj':'北京','sh':'上海'}" label="住址" name="address"></s:select>it

<s:submit value="登陸"></s:submit>io

</s:form>form

</fieldset>

</body>


action代碼

聲明三個與表單相同name的變量

private String address;

private String username;

private String sex;

生成set get方法


public String add() throws Exception {


   System.out.println(sex);

   System.out.println(address);

   System.out.println(username);


   tojsp="zhuceshow.jsp";

   return SUCCESS;

}


struts.xml

<action name="*tags" class="com.shxt.st.action.TagsAction" method="{1}">

<result name="success">/${tojsp}</result>

</action>


zhuceshow.jsp

<body>

<fieldset>

<legend>顯示註冊信息</legend>

<s:textfield name="username" label="用戶名"></s:textfield>

<s:radio list="#{'0':'男','1':'女','3':'待定'}" name="sex2" value="sex" label="性別"></s:radio>

<s:select list="#{'cc':'長春','bj':'北京','sh':'上海'}" label="住址" value="address"></s:select>

</fieldset>

</body>

相關文章
相關標籤/搜索