Announcement Announcement Module
Collapse
No announcement yet.
weird problem with URL encoding on redirect. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • weird problem with URL encoding on redirect.

    I have a controller with 2 handler methods in it. One of the controllers creates a redirect like so

    Code:
           UriComponents redirectUri = UriComponentsBuilder.fromPath("/shelflocation/view")
                .queryParam("shelfLocationId", shelfLocation.getId()).build().encode();
            return "redirect:"
                + redirectUri.toUriString();

    And the handler method I am calling looks like this:

    Code:
        @RequestMapping(value = "/view", method = RequestMethod.GET)
        public ModelAndView view(@RequestParam(value = "shelfLocationId", required = true)
        final long id)
        {
    Now I dont think there is any problem with the handler method because I call into that same view handler from a jsp via link like this:
    Code:
    <a target="_blank" href="<c:url value="/shelfLocation/view?shelfLocationId='+shelfLocationId+'"/>">
    and that works fine.

    As a matter of fact I can copy and paste the link out of the browser address bar and into a new tab and it works in one case and in the other it does not. Yet to my eye they look identical.

    Here are the links:

    The below link is generated on the redirect and does not work. I cannot copy and paste this into a new browser tab and get in my handler method.
    http://localhost:8080/storedashboard...ocationId=1000

    The below link is generated from the href link in the jsp. It does work. I can copy and paste it into a new tab on my browser and get into my handler method.
    http://localhost:8080/storedashboard...ocationId=1000

    Has anyone ever experienced an issue like this before?

    Thanks,

  • #2
    Damn I spent all morning on this. Apparently I had c+p some portion of the redirect String and something goofy happened in STS. What was there looked like what I pasted but apparently was not. Deleting the redirect:... portion and typing it out again fixed the problem.

    Comment

    Working...
    X