[Original]java Web Learning Note 02:javaweb Development directory structure

Source: Internet
Author: User

this blog is original: Integrated still Silicon Valley (http://www.atguigu.com) System tutorial (deep thank) and network of existing resources (blogs, documents, books, etc.), the source of resources I will markThe purpose of this blog: ① summary of their own learning process, equivalent to study notes ② to share their own experience to everyone, learn from each other, communication, not commercialcontent inevitably appear problems, welcome to correct, exchange, discussion, you can leave a message, can also be contacted by the following ways. I Internet technology enthusiasts, Internet technology enthusiastsWeibo: Ivan is in 0221qq:951226918

--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- -----------------------------

1.WEB Program Structure

1) A Web application is composed of a set of servlet,html pages, classes, and other resources that run on the Web server as a complete application, in a structured hierarchical directory form;

2) The files that make up the Web application are deployed in the appropriate directory hierarchy, and the root directory represents the "root" of the entire Web application;

3) Usually the directory of the Web application is placed in the WebApps directory , each subdirectory under the WebApps directory is a standalone Web application, the name of the subdirectory is the name of the Web application, which is the "root" of the Web application. The user accesses the resources in the Web application through the root of the Web application.

4) One example: The directory hierarchy of the Web application defined by the servlet specification

Note: Both the classes and LIB directories in the ①web-inf directory can hold Java class files, and when the servlet container runs, the WEB application's ClassLoader will first load the classes directory, followed by the classes in the Lib directory. If a class with the same name exists under both directories, the class that will work is the classes directory

②web-inf is a special directory (all letters are capitalized). This directory is not part of the context path that the Web application can access, which is not visible to the client. However, the contents of this directory are visible to the servlet code

5) The relevant provisions in Tomcat: http://localhost:8080/docs/appdev/deployment.html

2. About configuring Web applications in any directory

· The virtual directory can be configured in the Web server, and the real directory corresponding to the virtual directory can be under any path;

· In the Tomcat server, this is done primarily in the XML configuration file through the <Context> element's settings. A <Context> element represents a Web application that runs in a specific virtual host;

· The <Context> element is a child of the <Host> element, and you can set the Context element in the Conf\server.xml file

  

1) The:<context> element is a child of the <Host> element, and you can set the Context element in the Conf\server.xml file

Use the Docbase property to specify the true path of the Web application. Setting the property reloadable to True,tomcat automatically monitors changes to the servlet class at run time, and if a class is found to be updated, the Tomcat server will automatically reload the Web application. This way, there is no need to restart Tomcat frequently at development time.

2) mode two: create the Catalina\localhost directory in the $TOMCAT/conf directory , then create an app name for your app in the localhost directory . XML (the corresponding application's XML description file, for example, Test.xml) edit this file to enter the following content

<context path= "/test" docbase= "C:/test" reloadable= "true"/>

Starting with Tomcat 5.5, creating an XML configuration file in the \conf\catalina\localhost directory to configure the Web application, Tomcat will use the file name of the XML file as the context path for the Web application, regardless of the < What is the context path specified in the Path property of the context> element. Because the version after Tomcat 5.5 is the context path of the Web application with the file name of the XML configuration file, the Path property can be used without the configuration <Context> element

3. Finally, two sentences

1) for the web directory structure must have some understanding, for development, the general directory is a lot of complexity. Familiar with the directory structure can easily locate code failures

2) Learn about Tomcat's WebApp and work directory

3) This blog is a basic understanding of Java Web projects, in the development of Eclipes has a very good automated way.

[Original]java Web Learning Note 02:javaweb Development directory structure

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.