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

          生活保健

          解析文件

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 日土县| 绥德县| 志丹县| 雷州市| 江西省| 隆安县| 阿尔山市| 鄯善县| 卢氏县| 延庆县| 毕节市| 定日县| 舒城县| 邓州市| 济阳县| 延长县| 巴南区| 天水市| 公主岭市| 荆州市| 桂平市| 临湘市| 宁海县| 泰顺县| 五家渠市| 晋宁县| 永安市| 辽宁省| 富源县| 凤庆县| 揭阳市| 安庆市| 叶城县| 五莲县| 双城市| 获嘉县| 内江市| 商南县| 沐川县| 怀化市| 改则县|