The path of the file introduced by the web. xml configuration during Spring MVC setup, mvcweb. xml

Source: Internet
Author: User

The path of the file introduced by the web. xml configuration during Spring MVC setup, mvcweb. xml

I am a relatively low person, haha. Originally, I had limited technology and had nothing to do. I had to prepare my own environment for fun. The results were blinded by various basic problems. Let's talk about the problem.

1. First, let's talk about the compiled java files. Normally, the files we write are generally java files, but eclipse will compile them for us. class file (there is an automatic compilation under the project). If no compilation is made, Project-> Build Project to compile the current project

2. What I mentioned above is very simple, but simply extending it further may cause some problems. I want to reiterate that I am relatively low. Some files are configured in web. xml, such as jdbc configuration and password configuration. These configuration files need web. xml to find these files and then load them in. In this way, the problem arises. How does he find the configuration file. Note: normal projects are running class files, compiled files, that is, files will be found in the compiled folder, so the directory structure of the project is easy to mislead the audience.

3. If you put the configuration file to be introduced under web-info, congratulations. You don't have to read it because you may not encounter Path Problems. Haha.

4. I first put it in web-info, but I didn't know what to do. Later I wanted to put the file under src. As a result, I was depressed when I couldn't find the configuration file. Ah, I can only say that the technology is not home. At this time, we use the project runtime mentioned above to find the file in the compiled folder, and the initial configuration is originally under web-info. when the project is running, go to the class file storage directory under web-info and configure to find a series of files, which will not cause errors. But now the location of the configuration file has been moved. The default class file storage location has not changed and will continue to be used, but the file with its own configuration is unavailable in web-info, the configuration file cannot be found.

5. The reason is clear: the class file storage location and configuration file location are not configured in the web-info directory.

6. Back up the configuration file (web. xml and all imported jar packages) before modification)

7. Right-click the project -- properties -- java build path -- Source and you will see the compilation path. This is my modified myFirstBlood/WebContent/WEB-INF/classes. After modification, the web. xml and jar packages will be lost. You need to try again. Then configure the path of the introduced file in web. xml.

8. What I said may be flawed. If you forget to correct it, Do not spray it.

Refer:

In spring mvc web. xml, what does classpath mean? First, the parameter is defined in web. xml and passed to Servlet.

Therefore, <param-value> </param-value> is interpreted as the servlet that receives this parameter.
This parameter of dispatchservlet defines the location of the configuration file.

Spring abstracts the processing of resource files and declares the file location in a URI-compliant manner,
The specific implementation class will parse this string (see the spring Resource documentation)
Use the appropriate method to read data according to the statement.

1. classpath: Indicates finding the target file from classpath.

The classpath of web application contains all jar packages and WEB-INF/classes directories under the WEB-INF/lib

2. Compiled class path. /WEB-INF/classes/

 

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.