[email protected]请求方法限定与请求参数限定

 

一.请求方法限定

除了可以对url进行设置,还可以限定请求进来的方法

  1. 限定GET方法

@RequestMapping(method = RequestMethod.GET)

 

如果通过POST访问则报错:

HTTP Status 405 - Request method 'POST' not supported

 

例如:

@RequestMapping(value = "itemList",method = RequestMethod.POST)

 

  1. 限定POST方法

@RequestMapping(method = RequestMethod.POST)

 

如果通过GET访问则报错:

HTTP Status 405 - Request method 'GET' not supported

 

  1. GET和POST都可以

@RequestMapping(method = {RequestMethod.GET,RequestMethod.POST})

 

二.请求参数限定

[email protected]请求方法限定与请求参数限定

请求:

http://localhost:8099/20181022_springmvc/query.action

[email protected]请求方法限定与请求参数限定

http://localhost:8099/20181022_springmvc/query.action?name=123

[email protected]请求方法限定与请求参数限定

 

相关文章:

  • 2021-09-06
  • 2022-12-23
  • 2021-10-03
  • 2022-01-22
  • 2022-12-23
  • 2021-07-02
  • 2021-09-11
猜你喜欢
  • 2021-11-04
  • 2022-12-23
  • 2021-05-10
  • 2022-12-23
  • 2022-01-07
  • 2021-08-14
  • 2022-12-23
相关资源
相似解决方案