Hi everyone and thanks a lot for helping and excuse me for my rusty english :).
I was trying to create a mvc website with spring 3.x , spring-security ,and .jsp pages, i can paste a lot of code here but i think it will be useless because it is a kind of logic problem on how the URI of the action and the uri of the controller works:
1)Jsp pages:
login: avalaible to all guests and return homeAdmin for admins with action "home" or
homeUser : for users with the action
homeAdmin : provides a menu with different actions mapped with " admin/action"
HomeUser : provides a menu with different actions mapped with " user/action"
UserLIst: a page that list every users and their information in a table
2)Controller :
guest controller: no class controller ,there are only two methods. First for mapping value={ "/, home"} and latter for "login". So everyone that try to do a request will be redirect to the login page for be able to login
@Controller
public class LoginController {
@RequestMapping(value={"/home","/"}
(code)//if admin homeAdmin else homeUser
return new ModelAndView("home");
@RequestMapping(value="/login", method = RequestMethod.GET)
(code)
return new ModelAndView("login");
....
There is a requestmapping for the class with the value "/admin/" for map the first part of the Uri-action;and there are different methods with the request mapping for a specificated action , like list User.
AdminController
@controller
@RequestMapping("/admin")
public class AdminController {
@RequestMapping(value={"/list", "/adminFilm"})
(code)
return new ModelAndView("adminFilm");
...
Now i do login as admin and my URL became
"localhost:8080/name_project/homeAdmin.jsp"
which is URI corresponding to URL
"/webapp/metainf/views/homeAdmin.jsp"
(generated by method InternalResuorceViewResolver into its xml page).
Pressing the button "List User" I perform an action="admin/list", now my URI is
"localhost:8080/name_project/admin/listUser.jsp"
At this point any of my action don't need to generate "admin/" because is alredy in the path but if try to logout (j_springsecurity_Logout) my URL in the top becames from
"localhost:8080/name_project/admin/listUser"
,
to
"localhost:8080/name_project/admin/j_spring_Logout"
so i get (naturally) an error for a mapping not found.
Same problem appears for homepage request because it is mapped by LoginController and not in AdminController, so when i request it from any page that have path "/admin/home", this is not found and can't call the controller in loginController.
I could solve it forcing paths of jsp pages, but it's bad programming (and generates errors). How can i solve this problem of paths?
If problem isn't understandable, I'll try to re-write it.
Thanks.