Ant风格资源地址支持3种匹配符
-?:匹配文件名的一个字符
-* : 匹配文件名中的任意字符,一层
-**:匹配多层路径
@RequestMapping还支持Ant风格的URL
第一种*
创建antStyle方法,重点是@RequestMapping("/*/antStyle")
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>
运行成功
第二种**
创建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>