Analysis of an issue where static files cannot be loaded when you start a SPRING-MVC project in eclipse

Source: Internet
Author: User

Problem performance:

Eclipse in the use of the SPRING-MVC framework to develop Web projects, the project will be able to access the JSP page after normal startup, but the JSP page page effect does not take effect, and prompted the JSP file hint JS can not find, 404 error.

(1) Preliminary judgment:

When debugging in the browser, JSP page prompt JS file can not find, prompt 404 error. Because the project name is Littlec-exchange-center, the URL in the access is Exchangecenter, the initial judgment is the path is wrong.

Try to fix: View the Server.xml configuration under Tomcat's Conf path as follows:


As you can see, although the package file path under Tomcat is Littlec-exchange-center, the access path is/exchangecenter. So the path is fine.


(2) Continue to look for: in the browser source view can not find the JS file, but the project package into Tomcat has JS file, further judgment is JS and other static file access problems.

Try to solve: in the same path as the JSP file, create a new test.html, which writes "test". Direct access to localhost:8080/exchangecenter/test.html, or a 404 error is indicated.

You can basically determine the issue of static resource access. SPRING-MVC where static resource loading is configured in our defined Dispatcher-servelt.xml file, after spring-mvc3.0, it is recommended to use the configuration:

< Mvc:annotation-driven />

<mvc:resources Mapping="/resources/**/"  Location="/resources/"/> 

With this configuration, spring can be found when image,css and other files are placed in the resources file.



This article is from the "go it on the Road" blog, be sure to keep this source http://andrewli.blog.51cto.com/7625043/1925617

Analysis of an issue where static files cannot be loaded when you start a SPRING-MVC project in eclipse

Related Article

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.