Issues with "SPRINGMVC" Static resource access

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.