论坛首页 Web前端技术论坛

jquery easyUI+spring 关于页面跳转

浏览 8973 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-05-25  
1、登陆页面是通过jquery easyui做的,控制层是spring做的,现在就是输入用户名和密码提交页面表单到spring controller,在controller里跳转到主菜单页面,而不是通过controller返回值到login.jsp,再从login.jsp路到主菜单页面。
login.jsp代码如下:
<html>
<head>
<base href="<%=basePath%>">
<title>UserLogin</title>
<script type="text/javascript">
$(function(){
$('#form').form({
url:'<%=path%>/login.dox',
onSubmit: function(){
var flag=$('#form').form('validate');
return flag;
}
});
$('#login').panel({
title:'adsfasdf',
width:400,
height:500,
border:true
})
});
</script>
</head>
<body>
<div align="center">
<form id="form" method="post">
<table id="login" width="400" class="datagrid-toolbar1">
<tr>
<td height="50" align="center">
userName:
</td>
<td>
<input id="login_name" type="text" name="login_name"
class="easyui-validatebox">
</td>
</tr>
<tr>
<td height="50" align="center">
password:
</td>
<td>
<input id="login_pwd" type="password" name="login_pwd"
class="easyui-validatebox">
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="login"
style="width: 80px; height: 25px;">
<input type="button" id="reset" value="reset"
style="width: 80px; height: 25px;" />
</td>
</tr>
</table>
</form>
</div>
</body>
</html>


spring controller代码如下:
@RequestMapping("/login.dox")
public ModelAndView login(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ModelAndView mav = null;
boolean flag = false;
User bean = new User();
String pwd = "";
try {

bean.setLogin_name(request.getParameter("login_name"));
bean.setLogin_pwd(request.getParameter("login_pwd"));
if (StringUtil.isEmpty(bean.getLogin_name())) {
request.setAttribute("login_name", "* 登陆用户名检查失败!");
flag = true;
}

if (StringUtil.isEmpty(bean.getLogin_pwd())) {
request.setAttribute("login_pwd", "* 登陆密码检查失败!");
flag = true;
}

if (flag) {
return this.init(request, response);
}

int rsCount = employeeService.isExists(bean);

if (rsCount == 0) {
return this.init(request, response);
}
pwd = MD5.MD5Encode(bean.getLogin_pwd());
bean = (User) employeeService.Load(bean);

if (!pwd.equals(bean.getLogin_pwd())) {
request.setAttribute("login_pwd", "*用户不正确!");
return this.init(request, response);
}
HttpSession session = request.getSession();
session.setAttribute("userInfo", bean);
mav = new ModelAndView("/main/index"); //该地方指定跳转到主菜单页面。

} catch (Exception ex) {
ex.printStackTrace();
return this.init(request, response);
}
return mav;
}

实际情况中无法通过spring的controller跳转
请大家帮忙

   发表时间:2012-05-25  
$('#form').form({ 
  url:'<%=path%>/login.dox', 
  onSubmit: function(){ 
  var flag=$('#form').form('validate'); 
    return flag; 
  },
  success:function(data){   
     if (data.success == 'false') {
         $.messager.alert('提示',data.msg,'info');
     }else{
	location.href = 'main/index';
    }  
  } 
});



controller返回个map
map.put("success", "true");
map.put("msg", "消息");

 

0 请登录后投票
   发表时间:2012-05-28  
To make the form become ajax submit form
官方API是这样说form方法的。

这是个ajax提交,你要controller跳转页面换submit提交把。
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics