Get the App
SLTechnology News&Howtos  ›  Development  › 

How to get query parameters and path parameters by SpringMVC

Shulou Source: shulou.com Published: 2022-06-03 09:40:54 11月15日 Update

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.

Tags: Parameters paths queries articles more tests good practical content articles knowledge pages references help related input Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information OPPO Reno NVidia macOS Redmi