前端:
<script type="text/javascript"> $().ready(function(){ $("#register_btn").click(function(event){ var name=$("#name").val(); var password=$("#password").val(); var phonenumber=$("#phonenumber").val(); var type=$("#type").val(); $.post("register.do",{name:name,password:password,phonenumber:phonenumber,type:type},function(data){ if(data=="注册成功"){ alert(data); window.location.href="login.jsp"; }else{ alert(data); } }); }); });</script>
后台:
@RequestMapping("/register") public void register(User u,HttpServletResponse response) throws IOException{ response.setContentType("text/html;charset=utf-8"); PrintWriter out=response.getWriter(); String rs=userService.register(u); if(rs.equals("注册成功")){ out.print("注册成功"); }else if(rs.equals("该手机号已注册")){ out.print("该手机号已注册"); }else{ out.print("注册失败"); } out.flush(); out.close(); }
添加回答
举报
0/150
提交
取消