posts - 495,  comments - 11,  trackbacks - 0
index.jsp中设计表单(只包含<body>标签内的内容):

<body>

  <h4>请输入你的基本信息</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>

        电话:<inputtype="text"name="person.phone"/><br>

        <inputtype="submit"value="提交"/>&nbsp;&nbsp;<inputtype="reset"value="重置"/><br>

    </form>

  </body>

创建com.action包,其中写MyAction.java文件,注意它是ActionSupport类的子类。ActionSupport类在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 阅读(93) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: