Create a new Web project from scratch
1. Create a new MAVEN project without using archetype, the final result (the directory structure on the left and the pom.xml on the right)
2. Because it is a Web project, we manually add a WebApp directory. Under the directory according to personal development habits, you can create a new directory to store resource files and page JSP, and the Web. XML configuration file (static resource directory, such as jquery and other external references such as the Application page script js;jsp and Web. xml Hidden under Web-inf is a security consideration, only one index.jsp can be exposed outside)
is a version that can be run in the middle, if you want to take a step-by-step can be followed by the first to do
3. You can see that the index.jsp in the content, it is not ready to run? The answer is no, according to the servlet specification, we also lack one of the above mentioned Web. xml file, which is a servlet-based Java Web application configuration file, gives the servlet configuration description. A Servlet container, such as Tomcat, tells the file which classes to load, what parameters are set in the context, and how to handle requests from the browser.
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE Web-app Public "-//sun Microsystems, INC.//DTD Web Application 2.3//en" "Http://java.sun.com/dtd/web-app_2_3. DTD ">
<web-app xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
Xmlns= "Http://java.sun.com/xml/ns/javaee"
xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
Id= "webapp_id"
version= "3.0" >
</web-app>
In the basic Web. XML, we need to add components within the Web-app element, such as listener, filter, servlet, etc., based on the project needs, first of all we let the project start.
4. Add Maven packaging configuration. As shown, select Edit configurations
Then choose the green "+", add a Maven configuration, Command line is currently filled "clean package", other options to query Maven packaging configuration, after the configuration is completed to complete the package.
The result of the operation is as follows, the left column appears target one, the concrete will be related to the artifacts in the project structure.
5. Then add a tomcat configuration, as shown in the Red Circle section that needs to be added, as mentioned in the previous step.
6. Then the project will be successfully launched.
"Restudying" builds Web projects from scratch