@RequestMapping("/user/login")
public String login(@RequestParam("username")String username, @RequestParam("password") String password, Model model, HttpSession session){
if(username!=null&&password.equals ("123456"))
{
session.setAttribute ("loginUser",username);
return "redirect:/main.html";
}
else{
model.addAttribute ("msg","用户名或密码错误");
return "/index";
}
}
去掉/
@RequestMapping("/user/login")
public String login(@RequestParam("username")String username, @RequestParam("password") String password, Model model, HttpSession session){
if(username!=null&&password.equals ("123456"))
{
session.setAttribute ("loginUser",username);
return "redirect:main.html";
}
else{
model.addAttribute ("msg","用户名或密码错误");
return "index";
}
}