在index.jsp中設(shè)計(jì)表單(只包含<body>標(biāo)簽內(nèi)的內(nèi)容):
<body>
??<h4>請(qǐng)輸入你的基本信息</h4>
????<formname="infoForm"action="go.action"method="POST">
????????姓名:<inputtype="text"name="person.name"/><br>
????????性別:<selectname="person.sex">
?????????????<optionvalue="男">男</option>
?????????????<optionvalue="女">女</option>
????????</select><br>
????????地址:<inputtype="text"name="person.address"/><br>
????????電話(huà):<inputtype="text"name="person.phone"/><br>
????????<inputtype="submit"value="提交"/> <inputtype="reset"value="重置"/><br>
????</form>
??</body>
創(chuàng)建com.action包,其中寫(xiě)MyAction.java文件,注意它是ActionSupport類(lèi)的子類(lèi)。ActionSupport類(lèi)在com.opensymphony.xwork2.ActionSupport中。
packagecom.action;
importcom.bean.Person;
importcom.opensymphony.xwork2.ActionSupport;
publicclassMyActionextendsActionSupport {
????privatePersonperson;
????@Override
????publicString execute()throwsException {
???????//TODOAuto-generated method stub
???????returnSUCCESS;
????}
????publicPerson getPerson() {
???????returnperson;
????}
????publicvoidsetPerson(Person person) {
???????if(person ==null) person =newPerson();
???????this.person= person;
????}
}
posted on 2007-09-24 14:48
jadmin 閱讀(97)
評(píng)論(0) 編輯 收藏