@IocBean
@At("/login")
public class LoginController {
@Inject
private LoginService loginService;
@At("/login_user")
@POST
//@Ok("jsp:")
public boolean Login(@Param("login")Login login,HttpSession session) {
boolean a=false;
Login user = loginService.getUser(login.getUsername(),login.getPwd());
if(user==null){
return a;
}else if(user!=null){
a=true;
session.setAttribute("user",user.getId());
return a;
}
return a;
}
}
function login() {
var username=$("#username").val();
var pwd=$("#pwd").val();
alert($("#username").val());
alert($("#pwd").val());
$.post("/login/login_user"),{"login.username":username,"login.pwd":pwd},function (data) {
if(data==true){
console.log(data);
}else if(data==false){
alert("账号或密码错误");
}
}}
13 回复
@At("/login_user")
@POST
//@Ok("jsp:")
public boolean Login(@Param("::login.")Login login,HttpSession session, HttpServletRequest req) {
System.out.println(req.getParameter("login.pwd"));
System.out.println(req.getParameter("login.username"));
boolean a=false;
Login user = loginService.getUser(login.getUsername(),login.getPwd());
if(user==null){
return a;
}else if(user!=null){
a=true;
session.setAttribute("user",user.getId());
return a;
}
return a;
}
添加回复
请先登陆