InterviewSolution
Saved Bookmarks
| 1. |
What are the ways to use dot(.) in @PathVariable in Spring MVC? |
|
Answer» To ADD special character in it, add a regex mapping {q:.+} in @RequestMapping @RequestMapping("/site") PUBLIC CLASS SiteController { @RequestMapping(value = "/{q:.+}", method = RequestMethod.GET) public ModelAndView display(@PathVariable("q") String q) { logger.debug("Site : q : {}", q); return getModelAndView(q, "site"); } //...Now, for input /site/GOOGLE.com, “q” will display the correct google |
|