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

          生活保健

          解析文件

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 吉木乃县| 灌南县| 临海市| 东阳市| 安岳县| 大港区| 财经| 夏邑县| 石首市| 石家庄市| 通道| 勃利县| 炎陵县| 万山特区| 四平市| 青岛市| 永嘉县| 澄城县| 庆城县| 太仓市| 上饶市| 长泰县| 齐齐哈尔市| 梁山县| 谷城县| 道孚县| 若尔盖县| 鹤岗市| 温宿县| 金昌市| 恩施市| 河北区| 衡阳县| 波密县| 广昌县| 郧西县| 文昌市| 呼图壁县| 朔州市| 成武县| 青神县|