SpringMVC: @PathVariable value containing the plus (+) character

java, spring-mvc

Solution

Silly me! It was error in completely different part. I'm calling the controller using Ajax with some javascript processing involved and the bug is there - it replaces 'plus' with 'space' and than calls the server. Thanks everyone for their time with this.

Problem

I have problem with @PathVariable in SpringMVC controller. Whenever I pass string containing plus ('+'), plus gets replaced by space. Encoding the parameter doesn't help. So for example if I request url myapp/resend-validation/my+mail@gmail.com, I get "my mail@gmail.com" in my `email` variable. Same happens after requesting myapp/resend-validation/my%2Bmail@gmail.com My controller looks like this: ``` @RequestMapping(value = "/resend-validation/{email:.+}") public String resendValidation(@PathVariable String email, HttpServletRequest request, Model model) { //controller code here } ``` (the regular expresion in @RequestMapping's value is because of the dot in the email address, otherwise, value gets truncated after the dot. It doesn't affect my problem) Thanks in advance for any help.

Original source