Announcement Announcement Module
Collapse
No announcement yet.
Path Redirect Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Path Redirect

    Hi guys, I wanted to do something with my incoming controller requests.

    Let's say I type this

    Code:
    <a href="viewUsers.html">View Users </a>
    Inside the UserController, I want the method that invokes the viewUsers.html to be interpreted like this.

    Code:
    @RequestMapping(value="/user/viewUsers.html")
    public String viewUsers()...
    {
    ..
    return "user/viewUers";
    }
    Notice that on the @RequestMapping there is an /user/ prefix.

    How can this be done?
    When I do this, it gives an error.


    The reason I want to do is for for enabling better security on incoming requests.

    Code:
    <intercept-url pattern="/user/**" access="hasRole('ROLE_ADMIN')" />
    Thanks guys.

  • #2
    If my understanding is correct, you're trying to lock down all requests to /user/** to require admin permissions except for the custom login url? If so, intercept urls are processed in order. So something like:

    Code:
    <intercept-url pattern="/user/viewUsers.html" access="permitAll" />
    <intercept-url pattern="/user/**" access="hasRole('ROLE_ADMIN')" />
    -Andy

    Comment


    • #3
      Thanks for the the reply arthomps but my question was kinda aimed a little differently.

      Code:
      The problem is that if I have a link 
      <a href="viewUsers.html">View Users</a>
      
      How can I get this link mapped to the path 
      @RequestMapping(value="/user/viewUsers.html")
      
      instead of
      
      @RequestMapping(value="/viewUsers.html")
      
      If i have it <a href="viewUsers.html"> with the path /user/viewUsers.html, it gives me a resource not found 404.
      Is there also a way just to restrict folders in general?
      Like under /views/pages/user/. I want to restrict the user folder.

      Thanks.

      Comment


      • #4
        anyone please?

        Comment


        • #5
          For Pre-pocessing before it gets towards controller user HandlerInterceptor(may be its Implementation HandlerInterceptorAdaptor) here you can make it to /user/viewUsers.html and then at controller let it be mapped with /user/viewUsers.html

          Comment


          • #6
            Thanks, do you know anywhere I can find an example of this?

            Comment


            • #7
              <a href="<c:url value="/user/viewUsers.html">">View Users</a>

              Comment


              • #8
                Andrei, I wanted to do that also, but that extra /user/ doesn't seem so clean.

                Comment


                • #9
                  For HandlerInterceptor/HandlerInterceptorAdaptor just look into reference doc here.

                  Comment

                  Working...
                  X