dimanche 12 avril 2015

request mapping after login in spring annotation

Initially my url is



http://localhost:8081/UserLogin/


after login it will be



http://localhost:8081/UserLogin/login


then go to "add user" link and url will be


http://localhost:8081/UserLogin/admin/addUser


here admin is the session variable it can be admin/user/common etc. From add user form page back to home page should be



http://localhost:8081/UserLogin/admin/home


But now this is showing 404 error and in controller



//method to go back to home page
@RequestMapping(value = "/home")
public ModelAndView BacktoHome(HttpServletRequest request,
HttpServletResponse response,HttpSession session) {
String sessionUserRole = (String)
request.getSession().getAttribute("sessionUserRole");
return new ModelAndView("result", "role",
sessionUserRole);
}


and in add user jsp page:



<!--<% String sessionUserRole = (String) request.getSession().getAttribute("sessionUserRole"); %>
<c:set var="role" value="<%=sessionUserRole %>" />-->
<li class="admin-login active">Add User<h3><a href="home">BACK</a></h3></li>


how to set correct path in controller class request mapping. I found if i set



//method to go back to home page
@RequestMapping(value = "admin/home")
public ModelAndView BacktoHome


it is ok. but it will be dynamic like admin/user/common etc.


Please help!!


Aucun commentaire:

Enregistrer un commentaire