SpringMVC中@RequestMapping参数设置

URL路径由value决定,eg:value="/hello"。


  method参数:RequestMethod.POST,RequestMethod.GET请求方法,比如GET、POST


 除此之外,还有:


 param:参数设置


 @RequestMapping还支持ANT风格的通配符:

@RequestMapping(value="/?/world")

需要类似于http://localhost:8080/SpringHelloWorld/hello/4/world这样的请求才可以请求;4的位置可以换成任意一个字符但是必须有。

 @RequestMapping(value="/*/world")

需要类似于http://localhost:8080/SpringHelloWorld/hello/aaaaaaaaaaaaaaaaaa/world这样的请求才可以请求;aaaaaaaaaaaaaaaaaa的位置可以换成任意多个(至少一个)字符但是必须有。

 @RequestMapping(value="/**/world")

http://localhost:8080/SpringHelloWorld/hello/world可以处理该请求

http://localhost:8080/SpringHelloWorld/hello/1/2/3/4/world也可以处理该请求

也就是说,这种统配是可以中间掺杂任意多个这种结构,也可以没有;

 

posted @ 2018-06-20 21:57  呦,可以呦  阅读(396)  评论(0编辑  收藏  举报