spring mvc中什么时候用method = requestmethod.get什么时候用method = requestme
1个回答
2014-12-10
展开全部
//如: 仅GET方式
@RequestMapping(value = "hello",params ="what",method =RequestMethod.GET)
//如: 仅POST方式
@RequestMapping(value = "hello",params ="what",method =RequestMethod.POST)
以上都可以正常工作但是我如果想要同时支持POST和GET,有看到如下写法:
@RequestMapping(value = "hello",params ="what",method ={RequestMethod.POST,RequestMethod.GET})
@RequestMapping(value = "hello",params ="what",method =RequestMethod.GET)
//如: 仅POST方式
@RequestMapping(value = "hello",params ="what",method =RequestMethod.POST)
以上都可以正常工作但是我如果想要同时支持POST和GET,有看到如下写法:
@RequestMapping(value = "hello",params ="what",method ={RequestMethod.POST,RequestMethod.GET})
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询