- Java code
public String loginOn() throws IOException{ String resultStr = SUCCESS; HttpServletResponse response = ServletActionContext.getResponse(); response.getWriter().print("{success:true,msg:'登录成功!'}"); return resultStr;}[code]这是我action中这样写的。。[code=JScript]login : function() { if (this.fp.form.isValid()) { this.fp.form.submit({ waitTitle : '请稍候', waitMsg : '正在登录......', url : 'user/loginOn.action', success : function(form, action) { Ext.Msg.alert('提示', action.result.msg); }, failure : function(form, action) { form.reset(); Ext.Msg.alert('警告', action.result.msg); } }); } }
输入密码登陆后,总等不到值 action.result.msg,有时候还会有脚本错误!
更奇怪的是:按照action的代码,每次都应该是成功的。应该走js中的success 函数,可是每次都走进failure。。。
请高手指点,,,我都纠结了一天办了。。不知道为什么。。。求救,,问题解决200分送上。。。
------解决方案--------------------
login : function() {
if (this.fp.form.isValid()) {
this.fp.form.submit({
waitTitle : '请稍候 ',
waitMsg : '正在登录...... ',
url : 'user/loginOn.action ',
success : function(response, action)
{
if( " " != response.responseText)
{
var json = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert( '提示 ', json.msg);
} },
failure : function(response, action) {
form.reset();
Ext.Msg.alert( '警告 ', '错误 ');
}
});
}
}
------解决方案--------------------
login : function() {
if (this.fp.form.isValid()) {
this.fp.form.submit({
waitTitle : '请稍候 ',
waitMsg : '正在登录...... ',
url : 'user/loginOn.action ',
success : function(response, action)
{
if( " " != response.responseText)
{
var json = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert( '提示 ', json.msg);
} },
failure : function(response, action) {
form.reset();
Ext.Msg.alert( '警告 ', '错误 ');
}
});
}
}
------解决方案--------------------
后台msg 有没有get set 方法
------解决方案--------------------
function login() {
if (formLogin.getForm().isValid()) {
formLogin.getForm().submit({
url : "loginjson/login.action",
waitMsg : "正在登录请稍候",
waitTitle : "提示",
method : "POST",
success : function(form, action) {
if (action.result.lang == 1) {
window.location.href = "Console/index.jsp";
} else {
window.location.href = "Console/index.jsp";
}
},
failure : function(form, action) {
Ext.Msg.alert("提示", action.result.msg);
}
})
}
}
------解决方案--------------------
public String loginOn() throws IOException{
//String resultStr = SUCCESS;
HttpServletResponse response = ServletActionContext.getResponse();
response.getWriter().print("{success:true,msg:'登录成功!'}");
//return resultStr;
return null;
}
ajax请求也返回值(SUCCESS)吗,return null
------解决方案--------------------
xml名称不配对,麻烦把你先走报错的信息贴出来
------解决方案--------------------
action
getResponse().getWriter().write("{success:true,isOrder:true}");
getResponse().getWriter().flush();
页面
success: function(WhitelistForm,o){
var isOrder = o.result.isOrder;
------解决方案--------------------
我可以来拿点分吗?
------解决方案--------------------
- Java code
//actionpublic String query(){ try{ json=this.getUserService().queryUsers(); outJsonString(json); success=true; return null; //注意返回是null }catch(Exception e){ e.printStackTrace(); return "error"; } }//servicepublic String queryUsers(){ System.out.println("struts2 userService"); List<User> list=this.getUserDao().queryUsers(); //String str = this.getJsonarray().fromObject(list).toString(); //String json = "{\"totalProperty\":"+list.size()+",\"success\":true,\"root\":"+str+"}"; // System.out.println(json); String str="[{\"userno\":\"1\",\"userpassword\":\"q123456\",\"username\":\"li\"}]"; String json = "{totalProperty:1,root:"+str+"}"; return json; //\"success\":true, }
------解决方案--------------------
方便的话将代码发到我邮箱zxingchao2005@126.com我看看
------解决方案--------------------
美女 不 留恋csdn了,要经商了。