Some static resources are often used in the project, and generally we let SPRINGMVC take over all requests (including access to static resources) when configuring SPRINGMVC.
So how can we be the simplest to configure access to static resources?
One, let SPRINGMVC take over all requests in Web. xml
Second, configure the static resource mapping path in SPRINGMVC
This means to map the access path of the CCC folder to JavaScript.
That is, in the address bar to access a picture under JavaScript, in fact, after SPRINGMVC processing, access to the CCC file
For example we want to visit localhost:8080/test/javascript/a.jpg actually will go to Webroot under the CCC folder to find A.jpg file
Do not say mapping and location to confuse, online too many blog is copied, a person wrote wrong, everyone is wrong, fraught is drunk!
Third, some online blogs often let everyone in the configuration of static resources when adding this sentence
<mvc:default-servlet-handler/>
Add this sentence, you will find that SPRINGMVC not fully take over the request Ah, I request webroot The following file, do not configure the corresponding mapping path in SPRINGMVC, why can I request it?
The reason is that after you add <mvc:default-servlet-handler/>, you will use SPRINGMVC default set of static resource access, so you access the static resources without mapping the path can be directly accessed!
At this point, Springmvc's static resource access is OK.
Issues with "SPRINGMVC" Static resource access