Skip to content

Flash attributes not working with spaces in query parameters [SPR-12569] #17170

Closed
@spring-projects-issues

Description

@spring-projects-issues

Ivan Stojić opened SPR-12569 and commented

Flash attributes don't seem to be working when redirecting to a URL with query parameters which contain spaces (which get encoded as a '+' character), e.g. /test?param=hello+there .

I've created a simple Spring Boot (1.2.0) application which can be used to test this issue:

@EnableAutoConfiguration
@Controller
public class DemoApplication {

    @RequestMapping("/")
    @ResponseBody
    String hello(ModelMap model) {
        String name = (String)model.getOrDefault("name", "???");
        return "Hello, " + name + "!";
    }

    @RequestMapping("/test1") // OK
    String test1(RedirectAttributes redir) {
        redir.addFlashAttribute("name", "World");
        return "redirect:/";
    }

    @RequestMapping("/test2") // OK
    String test2(RedirectAttributes redir) {
        redir.addFlashAttribute("name", "World");
        return "redirect:/?param=1";
    }

    @RequestMapping("/test3") // NOT WORKING
    String test3(RedirectAttributes redir) {
        redir.addFlashAttribute("name", "World");
        return "redirect:/?param=1+2";
    }

    @RequestMapping("/test4") // NOT WORKING
    String test4(RedirectAttributes redir) {
        redir.addFlashAttribute("name", "World");
        redir.addAttribute("param", "1 2");
        return "redirect:/";
    }

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

Affects: 4.1.3

Issue Links:

Referenced from: commits spring-attic/spring-framework-issues@3b66b10, spring-attic/spring-framework-issues@7cd7012

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions