关于spring mvc 的alwaysUseFullPath配置

来源:互联网 发布:db2数据库创建用户 编辑:程序博客网 时间:2024/05/01 18:52

Spring MVC的URL映射有一个控制路径匹配的参数alwaysUseFullPath,不配默认为false如下:


org.springframework.web.util.UrlPathHelper 的getLookupPathForRequest方法可知,当alwaysUseFullPath为true时使用getPathWithinApplication获得待查找的全路径,否则使用getPathWithinServletMapping获得待查找的剩余路径。


表现案例:

1、alwaysUseFullPath设置为true时,匹配规则是取   请求路径----》完整的key值

<property name="mappings">
      <props>

     <prop key="/json/uploadfile">jsonUploadFileController</prop>

     </props>
</property>

请求路径应为:/json/uploadfile

2、alwaysUseFullPath设置为false时,匹配规则是取   请求路径最后一个/ ----》完整的key值

<property name="mappings">
      <props>

     <prop key="/uploadfile">jsonUploadFileController</prop>

     </props>
</property>

请求路径应为:/json/uploadfile或者/uploadfile