/*配置一个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.
/*配置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.