【发布时间】:2015-06-14 08:36:18
【问题描述】:
当前路径显示
http://localhost:8081/UserLogin/login
但我想要这个
http://localhost:8081/UserLogin/index
or
http://localhost:8081/UserLogin/
我的控制器类是
@RequestMapping(value = "/login" ,method = RequestMethod.POST)
public ModelAndView test(HttpServletRequest request, HttpServletResponse response) {
//return "hi this is a test";
String userName = request.getParameter("data[Admin][user_name]");
String userPass=request.getParameter("data[Admin][password]");
int userId=userDAO.getUser(userName, userPass);
if(userId!=0){
String message = "welcome!!!";
return new ModelAndView("result", "message", message);
}
else{
String message = "fail";
return new ModelAndView("index", "message",message);
}
}
想在不匹配时改变 else 条件。 提前致谢。 :)
【问题讨论】:
标签: spring model-view-controller annotations