Ant风格资源地址支持3种匹配符spring
-?:匹配文件名的一个字符mvc
-* : 匹配文件名中的任意字符,一层app
-**:匹配多层路径jsp
@RequestMapping还支持Ant风格的URLcode
第一种*资源
建立antStyle方法,重点是@RequestMapping("/*/antStyle")class
public class helloworldhandler { @RequestMapping(value="/hello",method=RequestMethod.GET,params= {"name=tom","age!=12"},headers={"accept=text/class"}) public String hello() { System.out.println("欢迎走进spring MVC,你建立的第一个方法成功了"); return "success"; } @RequestMapping("/*/antStyle") private String antStyle() { // TODO Auto-generated method stub System.out.println("欢迎走进antsyle"); return "success"; } }
index.jsp修改相应路径:方法
</head> <body> <a href="springmvc/hello?name=tom&&age=11">hello world</a> <br/> <a href="springmvc/l/antStyle">hello world</a> </body>
运行成功im
第二种**img
建立antStyle方法,重点是@RequestMapping("/**/antStyle")
index.jsp路径:<a href="springmvc/l/antStyle">hello world</a>
第三种?
建立antStyle方法,重点是@RequestMapping("/?/antStyle")
只容许一个字符的路径
index.jsp路径:<a href="springmvc/a/antStyle">hello world</a>