Announcement Announcement Module
Collapse
No announcement yet.
Problem with ViewResolver with redirect Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with ViewResolver with redirect

    Hi,
    Am facing problem with viewResolver while redirecting to a jsp.
    The scenario is as follows:
    1. User logins from a login.jsp. Authentication is done in a controller and the control is forwarded to a 'HomePage.jsp'.
    Now if the user refreshes the 'HomePage.jsp' the LoginController is called again as the browser url is still the same as for Login. (No redirect here).
    To solve the issue i changed the forward to a redirect
    Code:
    return new ModelAndView("redirect:UserHome");
    Am using ViewResolver which adds prefix as "/jsp" and suffix as ".jsp". However these prefix and suffix are not added when using Redirect and the url formed is http://localhost/WebApp/UserHome

    My question is
    1) Is redirection the correct way to solve refresh button problem?
    2) If yes, then how should I use viewResolver along with redirect tag?

    Thanks,
    Kapil

  • #2
    when using a redirect you will have to use a full URL. The part after the redirect: isn't used to resolve the view, a direct redirect is issued to the browser with the part after the redirect:.

    Comment


    • #3
      Thanks for your quick reply mdeinum.
      If complete url is need for redirect then I won't be able to keep my jsp in Web-Inf directory.
      Is there a way to avoid redirect and also to avoid hitting the same login url on refresh

      Comment


      • #4
        Anyone having an idea abt this issue?
        Thanks,
        kapil

        Comment


        • #5
          Simply configure a UrlFilenameViewController that way you can redirect to UserHome.do and the UrlFilenameViewController will resolve it to UserHome.jsp.

          Comment

          Working...
          X