Ant风格的请求映射

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>

231741_UC2T_3829307.png

运行成功

第二种**

创建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>

转载于:https://my.oschina.net/u/3829307/blog/1795980

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值