[email protected]请求方法限定与请求参数限定
[email protected]请求方法限定与请求参数限定
一.请求方法限定
除了可以对url进行设置,还可以限定请求进来的方法
- 限定GET方法
@RequestMapping(method = RequestMethod.GET)
如果通过POST访问则报错:
HTTP Status 405 - Request method 'POST' not supported
例如:
@RequestMapping(value = "itemList",method = RequestMethod.POST)
- 限定POST方法
@RequestMapping(method = RequestMethod.POST)
如果通过GET访问则报错:
HTTP Status 405 - Request method 'GET' not supported
- GET和POST都可以
@RequestMapping(method = {RequestMethod.GET,RequestMethod.POST})
二.请求参数限定
请求:
http://localhost:8099/20181022_springmvc/query.action
http://localhost:8099/20181022_springmvc/query.action?name=123