Spring平常记录

1. spring mvc 关于url匹配html

    如对于url:http://localhost:8080/mypro/user/index.htmlspring

                      http://localhost:8080/mypro/user/indexjson

 

            后台配置是:user/index,而spring的defaultservlet配置是*.htmlmvc

        默认的匹配规则对于这两个url均可以访问到对应的 controller 方法,由于它默认开启useRegisteredSuffixPatternMatch=true,也就是说能够默认匹配后缀即:/user/index = /user/index.htmlurl

若是权限要求严格的项目 能够关闭这个选项code

<mvc:annotation-driven>
    <mvc:path-matching suffix-pattern="false" />
  </mvc:annotation-driven>
相关文章
相关标签/搜索