struts2 請求參數值的獲得

          action文件:
          public class HelloWorldAction {//id=123&name=aaa
           private Integer id;
           private Person person;
           public Person getPerson() {
            return person;
           }


           public void setPerson(Person person) {
            this.person = person;
           }

          實體bean文件:
          public class Person {
          //需要默認構造器,struts2利用反射機制獲得值
           public String getName() {
            return name;
           }
           public void setName(String name) {
            this.name = name;
           }
           public Integer getId() {
            return id;
           }
           public void setId(Integer id) {
            this.id = id;
           }
           private String name;
           private Integer id;
          }
          瀏覽器請求頁面:
          <form action="<%=request.getContextPath() %>/control/department/helloWordexecute.action">
          <!--    <form action="/control/department/helloWordexecute.action"> -->
               name:<input type="text" name="person.name">
               id:<input type="text" name="person.id">
               <input type="submit" value="send">
             </form>
          接受實體bean 值文件:

          <body>
             id=${person.id}<br>
             name=${person.name}

            </body>


          posted on 2012-06-05 10:23 youngturk 閱讀(856) 評論(2)  編輯  收藏 所屬分類: struts2

          評論

          # re: struts2 請求參數值的獲得[未登錄] 2013-07-04 16:13 liu

          123456  回復  更多評論   

          # re: struts2 請求參數值的獲得 2013-10-20 22:02 伊利討論區

          好像不需要這么復雜!  回復  更多評論   

          <2013年7月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          導航

          統計

          公告

          this year :
          1 jQuery
          2 freemarker
          3 框架結構
          4 口語英語

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          EJB學習

          Flex學習

          learn English

          oracle

          spring MVC web service

          SQL

          Struts

          生活保健

          解析文件

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 龙泉市| 隆昌县| 珠海市| 将乐县| 五寨县| 四子王旗| 巴林左旗| 象州县| 木兰县| 墨竹工卡县| 沂源县| 阳山县| 兰州市| 抚州市| 沂水县| 西畴县| 嵩明县| 扎囊县| 新田县| 普兰县| 勐海县| 彭泽县| 安平县| 桐乡市| 商都县| 万源市| 广德县| 邢台市| 比如县| 吉林市| 横山县| 阿城市| 那坡县| 东宁县| 芜湖县| 庐江县| 恩施市| 会理县| 叙永县| 德江县| 大荔县|