|
21 | 21 | import java.net.URLDecoder;
|
22 | 22 | import java.util.ArrayList;
|
23 | 23 | import java.util.List;
|
24 |
| - |
25 | 24 | import javax.activation.FileTypeMap;
|
26 | 25 | import javax.activation.MimetypesFileTypeMap;
|
27 | 26 | import javax.servlet.ServletException;
|
|
30 | 29 |
|
31 | 30 | import org.apache.commons.logging.Log;
|
32 | 31 | import org.apache.commons.logging.LogFactory;
|
| 32 | + |
33 | 33 | import org.springframework.beans.factory.InitializingBean;
|
34 | 34 | import org.springframework.core.io.ClassPathResource;
|
35 | 35 | import org.springframework.core.io.Resource;
|
|
51 | 51 | * (according to the guidelines of Page Speed, YSlow, etc.) by allowing for flexible cache settings
|
52 | 52 | * ({@linkplain #setCacheSeconds "cacheSeconds" property}, last-modified support).
|
53 | 53 | *
|
54 |
| - * <p>The {@linkplain #setLocations "locations" property} takes a list of Spring {@link Resource} locations |
55 |
| - * from which static resources are allowed to be served by this handler. For a given request, the |
56 |
| - * list of locations will be consulted in order for the presence of the requested resource, and the |
| 54 | + * <p>The {@linkplain #setLocations "locations" property} takes a list of Spring {@link Resource} |
| 55 | + * locations from which static resources are allowed to be served by this handler. For a given request, |
| 56 | + * the list of locations will be consulted in order for the presence of the requested resource, and the |
57 | 57 | * first found match will be written to the response, with {@code Expires} and {@code Cache-Control}
|
58 | 58 | * headers set as configured. The handler also properly evaluates the {@code Last-Modified} header
|
59 | 59 | * (if present) so that a {@code 304} status code will be returned as appropriate, avoiding unnecessary
|
60 | 60 | * overhead for resources that are already cached by the client. The use of {@code Resource} locations
|
61 |
| - * allows resource requests to easily be mapped to locations other than the web application root. For |
62 |
| - * example, resources could be served from a classpath location such as "classpath:/META-INF/public-web-resources/", |
63 |
| - * allowing convenient packaging and serving of resources such as a JavaScript library from within jar files. |
| 61 | + * allows resource requests to easily be mapped to locations other than the web application root. |
| 62 | + * For example, resources could be served from a classpath location such as |
| 63 | + * "classpath:/META-INF/public-web-resources/", allowing convenient packaging and serving of resources |
| 64 | + * such as a JavaScript library from within jar files. |
64 | 65 | *
|
65 | 66 | * <p>To ensure that users with a primed browser cache get the latest changes to application-specific
|
66 |
| - * resources upon deployment of new versions of the application, it is recommended that a version string |
67 |
| - * is used in the URL mapping pattern that selects this handler. Such patterns can be easily parameterized |
68 |
| - * using Spring EL. See the reference manual for further examples of this approach. |
| 67 | + * resources upon deployment of new versions of the application, it is recommended that a version |
| 68 | + * string is used in the URL mapping pattern that selects this handler. Such patterns can be easily |
| 69 | + * parameterized using Spring EL. See the reference manual for further examples of this approach. |
69 | 70 | *
|
70 |
| - * <p>For various front-end needs — such as ensuring that users with a primed browser cache get the |
71 |
| - * latest changes, or serving variations of resources (e.g., minified versions) — |
| 71 | + * <p>For various front-end needs — such as ensuring that users with a primed browser cache |
| 72 | + * get the latest changes, or serving variations of resources (e.g., minified versions) — |
72 | 73 | * {@link org.springframework.web.servlet.resource.ResourceResolver}s can be configured.
|
73 | 74 | *
|
74 | 75 | * <p>This handler can be configured through use of a
|
75 |
| - * {@link org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry} or the {@code <mvc:resources/>} |
76 |
| - * XML configuration element. |
| 76 | + * {@link org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry} |
| 77 | + * or the {@code <mvc:resources/>} XML configuration element. |
77 | 78 | *
|
78 | 79 | * @author Keith Donald
|
79 | 80 | * @author Jeremy Grelle
|
@@ -118,9 +119,8 @@ public List<Resource> getLocations() {
|
118 | 119 |
|
119 | 120 | /**
|
120 | 121 | * Configure the list of {@link ResourceResolver}s to use.
|
121 |
| - * |
122 |
| - * <p>By default {@link PathResourceResolver} is configured. If using this property, it |
123 |
| - * is recommended to add {@link PathResourceResolver} as the last resolver. |
| 122 | + * <p>By default {@link PathResourceResolver} is configured. If using this property, |
| 123 | + * it is recommended to add {@link PathResourceResolver} as the last resolver. |
124 | 124 | */
|
125 | 125 | public void setResourceResolvers(List<ResourceResolver> resourceResolvers) {
|
126 | 126 | this.resourceResolvers.clear();
|
@@ -272,7 +272,8 @@ protected Resource getResource(HttpServletRequest request) throws IOException {
|
272 | 272 | if (resource == null || getResourceTransformers().isEmpty()) {
|
273 | 273 | return resource;
|
274 | 274 | }
|
275 |
| - ResourceTransformerChain transformChain = new DefaultResourceTransformerChain(resolveChain, getResourceTransformers()); |
| 275 | + ResourceTransformerChain transformChain = |
| 276 | + new DefaultResourceTransformerChain(resolveChain, getResourceTransformers()); |
276 | 277 | resource = transformChain.transform(request, resource);
|
277 | 278 | return resource;
|
278 | 279 | }
|
|
0 commit comments