Eclipse web project path and released project path, eclipseweb

Source: Internet
Author: User

Eclipse web project path and released project path, eclipseweb

In enterprise development, we will create a javaWeb project. In eclipse, we refer to creating a dynamic web project. After the project is created, we can see the following project directory in IDE:

The main folders we care about are src, WebContent, WEB-INF, and test.

Src: stores the java files we have written and uses packages to differentiate the same files.

WebContent: released folder

WEB-INF: a secure folder that is stored if some content must be accessed through the background

Test: user-created user directory, which can store specific foreground files (such as html and jsp). In addition, you can create more folders to store different types of files.

The preceding figure shows the structure of the web project in IDE. What is the file path for publishing the web Project to tomcat:

 

We can see that the release path is the project name, there are three folders below META-INF, test, WEB-INF, you can clearly understand, after the release is the project name, then there is a file under WebContent (a folder in the development environment), and WebContent is not displayed, so it will be strange that my class file, don't worry, please refer:

 

Our class files are placed in the WEB-INF under the classes folder, the package path into a file path, such as com.cn. my into com/cn/my.

You may wonder, if I have a configuration file under src, where will my configuration file be released? According to the above explanation, src corresponds to the classes folder, the configuration file under src will be placed in the classes folder.

 

The <context-param> label configured in the web. xml file is described as follows:

1 <context-param>2             <param-name>log4j-properties-location</param-name>  3             <param-value>/WEB-INF/log4j.properties</param-value>4 </context-param>

The <param-value> value configured here refers to the/WEB-INF/log4j in relative paths. properties refers to the path after the release, where "/" refers to the root path, that is, Log4j (project name); log4j under the WEB-INF folder under the root path. properties file; where should we put this file in the development process (IDE, from the above explanation we know that the file under WebContent will maintain the original structure after the release, then we can conclude that the location in the IDE is: WebContent/WEN-INF/log4j. properties.

Most of the time, we will put the configuration file under src. What is the configuration change under src,

1. Put it in the src root path, the configuration above is changed to the following:

<context-param>            <param-name>log4j-properties-location</param-name>              <param-value>/WEB-INF/classes/log4j.properties</param-value>  </context-param>

2. Create a folder under src and configure it as follows:

<context-param>            <param-name>log4j-properties-location</param-name>              <param-value>/WEB-INF/classes/my/config/log4j.properties</param-value>  </context-param>

During development, we often see the following Configuration:

<param-name>log4j-properties-location</param-name>              <param-value>classpath:log4j.properties</param-value>          </param-name>

Classpath refers to the classes folder, which refers to the log4j. properties file under the src root path. You can also use classpath: test/my/log4j. properties

Please advise if something is wrong!

 

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.