Announcement Announcement Module
Collapse
No announcement yet.
RedirectView and URL encoding Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • RedirectView and URL encoding

    I'm using RedirectView to redirect a user to a login page where necessary. The idea is that I pass the original URL and any query parameters as an object in the ModelAndView, thus:

    Code:
    	String url = request.getServletPath();
    			String query = request.getQueryString();
    			RedirectView redirectView = new RedirectView(getLoginUrl());
    			redirectView.setContextRelative(true);
    			if (query != null) {
    				url += "?" + query;
    			}
    			ModelAndView modelAndView=new ModelAndView(redirectView);
    			logger.debug("Setting signonForwardAction to " + url);
    			modelAndView.addObject("signonForwardAction", url);
    			throw new ModelAndViewDefiningException(modelAndView);
    This works, but RedirectView is automatically imposing URL encoding, so that the URL redirected to appears thus:

    http://localhost/testapp/login.htm?s...on=%2Ftest.htm

    instead of

    http://localhost/testapp/login.htm?s...tion=/test.htm

    Is there a way of stopping this? Or, failing that, a way of URL decoding in the JSP? (I can't see any in JSTL).

  • #2
    To answer my own question, it appears that no decoding is necessary when I use the encoded form in a <c:url> tag - it 'reconstitutes' the URL correctly itself.

    Comment

    Working...
    X