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>