We generally face a problem when we hit server with path variable that contains special character like dot(.) it gets truncated.
For Example: If you have the mapping
@RequestMapping(value = "/findMe/{emailId}", method = RequestMethod.GET)
public ModelAndView findMe(HttpServletRequest request,
HttpServletResponse response,@PathVariable String emailId)
{
}
and you make the request to /findMe/user@gmail.com then you will get email = "user@gmail" and .com will not get displayed (Spring treats them as file extensions and removes them for you.).
Then to fix this issues you just need to provide regular expression for the @RequestMapping argument with the path variable as below:
@RequestMapping(value = "/findMe/{emailId:.+}", method = RequestMethod.GET)
public ModelAndView findMe(HttpServletRequest request,
HttpServletResponse response,@PathVariable String emailId)
{
}
Then for /findMe/user@gmail.com you will get email = "user@gmail.com"
Hope this will help you :)
0 Comment(s)