Extjs登陆验证问题,求救!若问题解决200分送上。

ladybirds2008 2011-05-31 12:17:59

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);
}
});
}
}
这是js中写的。。
输入密码登陆后,总等不到值 action.result.msg,有时候还会有脚本错误!
更奇怪的是:按照action的代码,每次都应该是成功的。应该走js中的success 函数,可是每次都走进failure。。。
请高手指点,,,我都纠结了一天办了。。不知道为什么。。。求救,,问题解决200分送上。。。

...全文
173 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
HELLPROJECTOR 2011-06-20
  • 打赏
  • 举报
回复
美女 不 留恋csdn了,要经商了。
playboy1001 2011-05-31
  • 打赏
  • 举报
回复
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);
}
})
}
}
playboy1001 2011-05-31
  • 打赏
  • 举报
回复
后台msg 有没有get set 方法
liuaaabbbccc 2011-05-31
  • 打赏
  • 举报
回复
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( '警告 ', '错误 ');
}
});
}
}
三心不可得 2011-05-31
  • 打赏
  • 举报
回复
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('警告', '错误');
}
});
}
}
UPC_思念 2011-05-31
  • 打赏
  • 举报
回复
方便的话将代码发到我邮箱zxingchao2005@126.com我看看
readme1988 2011-05-31
  • 打赏
  • 举报
回复

//action
public String query(){
try{
json=this.getUserService().queryUsers();
outJsonString(json);
success=true;
return null; //注意返回是null
}catch(Exception e){
e.printStackTrace();
return "error";
}
}
//service
public 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,
}


<struts> <constant name="objectFactory" value="spring"></constant> <include file="struts-default.xml" /> <package name="json" extends="json-default"> <action name="user" class="com.test.UserAction"> <result type="json"> </result> </action> </package> </struts>

注意下action与struts的写法
n7700111 2011-05-31
  • 打赏
  • 举报
回复
我可以来拿点分吗?
zn85600301 2011-05-31
  • 打赏
  • 举报
回复
action
getResponse().getWriter().write("{success:true,isOrder:true}");
getResponse().getWriter().flush();
页面
success: function(WhitelistForm,o){
var isOrder = o.result.isOrder;
_斑驳旳青春 2011-05-31
  • 打赏
  • 举报
回复
xml名称不配对,麻烦把你先走报错的信息贴出来
三心不可得 2011-05-31
  • 打赏
  • 举报
回复
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
ladybirds2008 2011-05-31
  • 打赏
  • 举报
回复
HttpServletResponse response = ServletActionContext.getResponse();
response.getWriter().print("{success:true,msg:'登录成功!'}");

我只要在action中加上这句话,他就有报错XML tag name mismatch (expected title)。只要不写的话 就是进success函数,并且action.result.msg 得到的为空,即result为undefined。。

这是为啥呢?????哭哭哭!!!!!!!!!!。。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧