首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

struts2 Action属性接受属性(2)

2012-10-07 
struts2 Action属性接受属性(二)和之前的那个 接受属性的不同点就是在于建立一个domain model 进而存储 属

struts2 Action属性接受属性(二)

和之前的那个 接受属性的不同点就是在于

建立一个domain model 进而存储 属性

乱码问题 加句话::?<constant name="struts.i18n.encoding" value="UTF-8" />

package com.chai.action;import com.chai.model.User;import com.opensymphony.xwork2.ActionSupport;public class UserAction extends ActionSupport{private User user;public String add (){System.out.println("username:"+user.getUsername());System.out.println("password:"+user.getPassword());return SUCCESS;}public User getUser() {return user;}public void setUser(User user) {this.user = user;}}

?

?

package com.chai.model;public class User {private String username;private String password;public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}}

?我们在传值的时候也应该有变化

  <body>   添加用户<a href="user/user!add?user.username=heihei&user.password=123asd">添加</a>  </body>

?

这里写user.username 和user.password

热点排行