ajax提交json时action接收不到对象数据但是能接收到action的单个属性
action的配置<packagename="useracton"namespace="/"extends="json-default"><actionname="log...
action的配置
<package name="useracton" namespace="/" extends="json-default">
<action name="login" class="userAction" method="login" >
<result>/index.jsp</result>
<result name="error" type="json">
<param name="root">msg</param>
</result>
</action>
</package>
var datas = {"user.userName":userName,"user.passWord":loginPwd,"msg":"好"}
alert(userName);
$.ajax({
url:"login.action",
data:datas,
dataType:"json",
type:"post",
error: function(data){
if(data.msg=="false"){
}
}
});
action类
@Controller("userAction")
public class UserAction extends ActionBase {
private static final long serialVersionUID = 6768226878085889112L;
private Users user;
private String msg = null;
public String login(){
System.out.println(msg);
System.out.println(user.getuserName()+"23");
for(Users user2:list){
if(user2.getpassWord().equals(user.getpassWord())){
user = user2;
session.put("loginUser", user);
return SUCCESS;
}
}
msg = "false";
return ERROR;
}
/////////////////getter和setter方法////////////////////////////////
public Users getUser() {
return user;
}
public void setUser(Users user) {
this.user = user;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
msg能收到数据但是user.userName却等null这是怎么回事? 展开
<package name="useracton" namespace="/" extends="json-default">
<action name="login" class="userAction" method="login" >
<result>/index.jsp</result>
<result name="error" type="json">
<param name="root">msg</param>
</result>
</action>
</package>
var datas = {"user.userName":userName,"user.passWord":loginPwd,"msg":"好"}
alert(userName);
$.ajax({
url:"login.action",
data:datas,
dataType:"json",
type:"post",
error: function(data){
if(data.msg=="false"){
}
}
});
action类
@Controller("userAction")
public class UserAction extends ActionBase {
private static final long serialVersionUID = 6768226878085889112L;
private Users user;
private String msg = null;
public String login(){
System.out.println(msg);
System.out.println(user.getuserName()+"23");
for(Users user2:list){
if(user2.getpassWord().equals(user.getpassWord())){
user = user2;
session.put("loginUser", user);
return SUCCESS;
}
}
msg = "false";
return ERROR;
}
/////////////////getter和setter方法////////////////////////////////
public Users getUser() {
return user;
}
public void setUser(Users user) {
this.user = user;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
msg能收到数据但是user.userName却等null这是怎么回事? 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
推荐于2016-02-18
展开全部
printPreviewDialog1.PrintPreviewControl.StartPage = 0;
class Composite : Component
{
private List children = new List();
public Composite(string name) : base(name) { }
public override void Add(Component c)
{
children.Add(c);
}
public override void Remove(Component c)
{
children.Remove(c);
}
class Composite : Component
{
private List children = new List();
public Composite(string name) : base(name) { }
public override void Add(Component c)
{
children.Add(c);
}
public override void Remove(Component c)
{
children.Remove(c);
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询