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 阅读(840) 评论(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

生活保健

解析文件

搜索

最新评论

阅读排行榜

评论排行榜