浏览 8992 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2012-05-25
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跳转 请大家帮忙 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间: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'; } } });
|
|
返回顶楼 | |
发表时间:2012-05-28
To make the form become ajax submit form
官方API是这样说form方法的。 这是个ajax提交,你要controller跳转页面换submit提交把。 |
|
返回顶楼 | |