Announcement Announcement Module
Collapse
No announcement yet.
Redirecting to a view from an interceptor Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Redirecting to a view from an interceptor

    Hi,

    I have an interceptor which does authentication before direction the request to certain set of pages. In this interceptor, I want to take actions based on whether the user cookie is set or not.
    If not present then show 'home' view
    If present but not valid then show 'invalid' view
    otherwise take him to the page

    Now, to redirect him to 'home' or 'invalid' view, I am using response.sendRedirect method which is creating following problems.
    1. I need to pass some params to this page. I have no choice but to use get params.
    2. It requires URL mapping for them as the redirection will happen from client
    3. If the logged in users access the pages directly, I want a separate behavior. They should go to the welcome page not these pages. For this, I have to put some checks in front of these two pages. This has to be done now because they are externaly visible (mapped to a URL). Anyone can access it.

    Isn't there a way to render a particular view from interceptor itself?

    Regards
    Prashant

  • #2
    I think you can use this:

    Code:
    ModelAndView mav = new ModelAndView("YOUR_SPECIAL_VIEW");
    throw new ModelAndViewDefiningException(mav);

    Comment


    • #3
      Hi,

      interceptor function prehandle only returns true/false. Refer this link for the function signature: http://static.springframework.org/sp...terceptor.html

      Regards
      Prashant

      Originally posted by m_auro1 View Post
      I think you can use this:

      Code:
      ModelAndView mav = new ModelAndView("YOUR_SPECIAL_VIEW");
      throw new ModelAndViewDefiningException(mav);

      Comment


      • #4
        Yes prashant2361,
        this method return a boolean value, but it can throw an exception

        Anyway, have you tried the code I have posted work and if it is usefull for you?

        Comment

        Working...
        X