Path problem of XML configuration introduction file in Spring MVC building process

Source: Internet
Author: User

Why to say so low problem, because I am a relatively low person, haha. Originally, I have limited technology, nothing to do their own took environment to find fun, the result is a variety of basic problems, get a face blind. Don't say more, just say the question.

1, first of all, the Java compiled files, normally we write files are generally Java files, but in fact, Eclipse will help us compile into a. class file (there is an automatic compilation under Project), without compiling, project->build Project to compile the current project

2, said above are very simple things, but the simple extension, there may be a bit of a problem, reiterate, I am relatively low. In Web. XML, some of the files that need to be introduced, such as JDBC configuration and password configuration, are configured. And these configuration files, need to have web. xml to find these files, and then load them in. So, the question is, how did he find the configuration file. Note that the normal project is running as a class file, a compiled file, which means that files are found under the compiled folder, so the project directory structure can easily mislead the audience.

3, if you put the need to introduce the configuration file, placed under the Web-info, then congratulate you, see this, you do not have to look down, because you may not encounter the path problem, haha.

4, I first put in the web-info, what did not, and then want to put the file under the SRC, the result, how configuration can not find the configuration file, I was depressed. Hey, can only say the technology is not home. At this time to use the above said the project run to the compiled folder to find files, and the first configuration is in the Web-info, the project runs, just go to web-info under and the configuration of the class file directory to find a series of files, this will not be wrong. But now move the configuration file location, the default class file storage location has not changed, will continue to use, but the web-info without their own files, will cause the configuration file can not be found.

5, the reason is clear, is the class file storage location, and configuration file location, not configured in the Web-info directory.

6, before the modification, make a backup of the configuration file (Web. xml and all imported jar packages)

7, right-click on the project--properties--java build Path--source, at this time to see the compilation path, this is my modified myfirstblood/webcontent/web-inf/classes. The Web. XML and jar packages before the modification are lost. Need to be re-visited once. Then go to the Web. XML to configure the path of the introduction file.

8, I said there may be flaws, forget the big God, do not spray ah.

Reference:

What does the classpath of this place mean in spring MVC's web. xml?First this is the Web. Xml method to define the parameters to the servlet.

So,<param-value></param-value> 's explanation is that the servlet that receives this parameter executes.
This parameter of Dispatchservlet is the location where the configuration file is defined.

In spring, the processing of resource files is abstracted, and the file location can be declared in a URI-compliant manner.
The specific implementation class will parse the string, (you can see spring's resource related documents)
Use the appropriate method to read according to the declaration inside.

1, Classpath: The beginning means to look for the target file from the classpath.

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

2. The compiled class path. /web-inf/classes/

Path problem of XML configuration introduction file in Spring MVC building process

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.