且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Spring 3.0 URL 模式验证

更新时间:2023-02-26 13:09:10

您可以在方法参数上使用 @PathVariable 注解.如果您需要验证变量的结构,@PathVariable 还允许使用正则表达式.

You can use @PathVariable annotation on a method argument. @PathVariable also allows regex if you need to validate the structure of the varible.

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping

http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/bind/annotation/PathVariable.html

对于正则表达式

http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/bind/annotation/RequestMapping.html