Announcement Announcement Module
Collapse
No announcement yet.
SessionLocaleResolver not working on redirect Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SessionLocaleResolver not working on redirect

    I have a SessionLocaleResolver which is set up in one controller, then redirects to a jsp (I use a redirect to update the URL just this once). However the jsp does not reflect the correct locale. I then click on one of the links in the jsp and travel to another controller, which does its business then forwards to another jsp. The locale in this second jsp is correct. Why would the locale not work when a jsp is accessed through a redirect, but work when forwarded to?

    Thanks

    p.s. If you need to see code, please let me know

  • #2
    You shouldn't redirect to a jsp directly but pass through the DispatcherServlet else it isn't going to work.

    Comment


    • #3
      Originally posted by Marten Deinum View Post
      You shouldn't redirect to a jsp directly but pass through the DispatcherServlet else it isn't going to work.
      Hi Marten,

      Can you clarify? I use the standard way of dispatching to views using the
      Code:
      return new ModelAndView("...");
      however I prepend "redirect:" to the view path. Is this way not going to pass through the DispatcherServlet? If not, how can I get around this. I need to use redirects occasionally.

      Thanks
      Last edited by Some_One; Sep 11th, 2008, 09:32 AM.

      Comment


      • #4
        It depends. If you redirect to a url which passes through the DispatcherServlet then it works. If you redirect to a jsp directly then it doesn't.

        Comment


        • #5
          By "redirect to a jsp directly" do you mean using Response.sendRedirect("...")?

          I am returning a ModelAndView object from my controller, so this should be going through the DispatcherServlet, no? Why wouldn't it work then?

          Thanks

          Comment


          • #6
            Code:
            redirect:whjateveroinhere.jsp
            direct redirection to a jsp...

            Comment


            • #7
              So then, to the second part of my question. If I occasionally need use direct redirection in my webapp, SessionLocaleResolver is useless, correct?

              Comment


              • #8
                No... Read.

                If you redirect to a JSP DIRECTLY it is useless. If you redirect to a url with passes through the DispatcherServlet (i.e. maps to a Controller) then it works. In fact you shouldn't have any jsp available directly, everything should be accessed through the DispatcherServlet.

                Comment

                Working...
                X