/*配置一个 handler 通过转发请求到 servlet 容器的默认 servlet 来处理静态资源*/ Configures a handler for serving static resources by forwarding to the Servlet container's default Servlet. /*使用该 handler 将会允许 DispatcherServlet 的 url-pattern 为'/'; 同时使用 servlet 容器的默认 servlet 处理静态资源*/ Use of this handler allows using a "/" mapping with the DispatcherServlet while still utilizing the Servlet container to serve static resources. /*该 handler 将会转发所有请求到默认 servlet*/ This handler will forward all requests to the default Servlet. /*因此将该 handler 的执行顺序放到所有请求处理的最后是非常重要的!!!*/ Therefore it is important that it remains last in the order of all other URL HandlerMappings. /*使用<mvc:annotation-driven/>标签或者设置 HandlerMapping instance 的 order 来确保 DefaultServletHttpRequestHandler 的 order 最大。*/ That will be the case if you use the "annotation-driven" element or alternatively if you are setting up your customized HandlerMapping instance be sure to set its "order" property to a value lower than that of the DefaultServletHttpRequestHandler, which is Integer.MAX_VALUE.
/*使用<mvc:annotation-driven/>标签或者设置 HandlerMapping instance 的 order 来确保 DefaultServletHttpRequestHandler 的 order 最大。*/ That will be the caseif you use the "annotation-driven" element or alternatively if you are setting up your customized HandlerMapping instance be sure to set its "order" property to a value lower than that of the DefaultServletHttpRequestHandler, which is Integer.MAX_VALUE.
也就是说,要么配置<mvc:annotation-driven />标签,要么手动注册请求映射处理 bean 于 xml 中,并设置 order 属性值,以其实现框架中处理请求映射的 bean 的 order 值小于 DefaultServletHttpRequestHandler 的 order 属性值!!!
/*配置 handler 为静态资源,如 images,js 和 CSS 文件并进行缓存头优化,以便在 Web 浏览器中高效加载。*/ Configures a handler for serving static resources such as images, js, and, css files with cache headers optimized for efficient loading in a web browser. /*允许为任何可以通过 spring 处理的路径资源提供服务*/ Allows resources to be served out of any path that is reachable via Spring's Resource handling.
{@code HttpRequestHandler} that serves static resources in an optimized way according to the guidelines of Page Speed, YSlow, etc.
* <p>The {@linkplain #setLocations "locations"} property takes a list of Spring * {@link Resource} locations from which static resources are allowed to * be served by this handler. Resources could be served from a classpath location, * e.g. "classpath:/META-INF/public-web-resources/", allowing convenient packaging * and serving of resources such as .js, .css, and others in jar files.