url pattern
Sep 27, 2016 2:32:31 PM org.apache.catalina.core.StandardContext checkUnusualURLPattern
INFO: Suspicious url pattern: "/**" in context [/zmvc] - see sections 12.1 and 12.2 of the Servlet specification
12.1 Use of URL Paths Upon receipt of a client request, the Web container determines the Web application to which to forward it. The Web application selected must have the longest context path that matches the start of the request URL. The matched part of the URL is the context path when mapping to servlets. The Web container next must locate the servlet to process the request using the path mapping procedure described below. The path used for mapping to a servlet is the request URL from the request object minus the context path and the path parameters. The URL path mapping rules below are used in order. The first successful match is used with no further matches attempted: 1. The container will try to find an exact match of the path of the request to the path of the servlet. A successful match selects the servlet. 2. The container will recursively try to match the longest path-prefix. This is done by stepping down the path tree a directory at a time, using the ’/’ character as a path separator. The longest match determines the servlet selected. 3. If the last segment in the URL path contains an extension (e.g. .jsp), the servlet container will try to match a servlet that handles requests for the extension. An extension is defined as the part of the last segment after the last ’.’ character. 4. If neither of the previous three rules result in a servlet match, the container will attempt to serve content appropriate for the resource requested. If a "default" servlet is defined for the application, it will be used. Many containers provide an implicit default servlet for serving content. The container must use case-sensitive string comparisons for matching.
12.2 Specification of Mappings In the Web application deployment descriptor, the following syntax is used to define mappings: ■ A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping. ■ A string beginning with a ‘*.’ prefix is used as an extension mapping. ■ The empty string ("") is a special URL pattern that exactly maps to the application's context root, i.e., requests of the form http://host:port/<contextroot>/. In this case the path info is ’/’ and the servlet path and context path is empty string (““). ■ A string containing only the ’/’ character indicates the "default" servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null. ■ All other strings are used for exact matches only. If the effective web.xml (after merging information from fragments and annotations) contains any url-patterns that are mapped to multiple servlets then the deployment must fail.
在Servlet规范中,关于 web.xml 的 url-pattern
<servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
两种格式:
- path mapping
- extension mapping
例如:/*
例如:*.do
规范中不存在 /** 上面的日志信息中指出 这是可疑的 ,请参考 Servlet 参考文档的 12.1 和 12.2 章节
spring mvc 中dispatcher 的url-pattern 不能配置成 /*
这种形式会拦截所有请求,却无法定向jsp文件 比如:URL [/WEB-INF/jsp/testresult.jsp]]
定向 jsp文件需要用到 tomcat 的 "jsp" servlet,该servlet 的 web.xml 在conf 文件夹下
同时 还有一个 "default" servlet
spring mvc 的 path pattern 中存在 /** 这种模式,详细查看spring 参考文档