前台用了jquery,后台用了 struts2框架。
前台:
$.ajax({
type : "POST",
url : "recmanager.action",
dataType : "json",
data : {
"manager" : $('#manager').val(),
"password":$('#password').val(),
//"manager.name" : $('#manager').val(), //"manager.password":$('#password').val(), }, 后台: public class ManagerAction extends BaseAction{ private Manager manager; public String recManager(){ System.out.println(manager.getName()+" "+manager.getPassword()); return "success"; }
}
pojo:
public class Manager implements Serializable{
private static final long serialVersionUID = 1L; public Manager(){ } private Integer id; private String name; private String password; private Integer level; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public Integer getLevel() { return level; } public void setLevel(Integer level) { this.level = level; }
}
问题:
前台的data:manager、password,怎样用struts2的特性跟后台的Manager对象属性绑定?
其中 前台我试过 manager.name/manager.password 这样传不行。
request.getParameter("manager.name");这样也为null,属性不带“.”符号可以通过
request.getParameter()取到。
人到中年有点甜
交互式爱情
相关分类