How to get query parameters and path parameters by SpringMVC
This article will explain in detail how to obtain query parameters and path parameters for SpringMVC. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Jsp page query.jsp
Title the id you entered is ${id} @ RequestParm to get the query parameter @ Controller@RequestMapping ("/ test") public class TestController {@ RequestMapping (value = "/ user", method = RequestMethod.GET) public String user (@ RequestParam ("id") int id, Map map) {map.put ("id", id); return "query";}}
You can visit the... / test/user?id=10 test above.
@ PathVariable gets the path parameter @ Controllerpublic class TestController {@ RequestMapping (value = "/ user/ {id}", method = RequestMethod.GET) public String user (@ PathVariable ("id") int id, Map map) {map.put ("id", id); return "query";}}
You can visit the... / user/10 test above.
This is the end of the article on "how to obtain query parameters and path parameters for SpringMVC". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.