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 閱讀(855) 評論(2)  編輯  收藏 所屬分類: struts2

          評論

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

          123456  回復  更多評論   

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

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

          <2012年6月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          1234567

          導航

          統計

          公告

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

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          EJB學習

          Flex學習

          learn English

          oracle

          spring MVC web service

          SQL

          Struts

          生活保健

          解析文件

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 康乐县| 荔浦县| 内江市| 大安市| 汾西县| 三原县| 绥棱县| 巴南区| 屏东市| 宁阳县| 班戈县| 仲巴县| 金阳县| 石阡县| 舞钢市| 海兴县| 灵石县| 阿鲁科尔沁旗| 惠来县| 龙口市| 沁水县| 罗城| 万全县| 余庆县| 仙游县| 临邑县| 襄垣县| 安化县| 中西区| 金华市| 利川市| 鹤庆县| 牙克石市| 安塞县| 海兴县| 孝义市| 辽宁省| 长垣县| 汉川市| 双桥区| 曲靖市|