mercredi 8 avril 2015

Change url path in Spring MVC by @RequestMapping

Currently path is showing



http://localhost:8081/UserLogin/login


But i want this as



http://localhost:8081/UserLogin/index
or
http://localhost:8081/UserLogin/


My controller class is



@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);
}
}


Want to change in else condition when not match. Thanks in advance. :)


Aucun commentaire:

Enregistrer un commentaire