Tomcat9 + eclipse: how to publish a website, tomcat9eclipse
Prerequisites: you have installed eclipse on your computer and can perform normal javase exercises. The following code runs javaee for the first time to demonstrate how to use tomcat + eclipse to publish a website.
1. Download tomcat9 and decompress it. Decompress apache-tomcat-9.0.0.m10.zip and put it on drive C (which disk can be put), and rename the folder as tomcat9.
Figure 01
Open C: \ tomcat9 \ bin, Enter cmd in the Command box, press enter to start command window 02, enter startup and press enter to start tomcat. Enter localhost: 8080 in the browser, press enter to open the default page 04.
Figure 02
Figure 03
Figure 04
2. configure server in Eclipse:
Window -- Preferences -- Server -- Runtime Environment
Click Add, select tomcat v9.0, next, set the tomcat path, and click finish.
Figure 05
Figure 06
3. Create a web project:
File-New-Project-Web-Dynamic Web Project
Enter the project name, follow the configuration, and click Finish.
Figure 07
4. display the small Servers window:
Window -- show view -- other -- Server-Servers option -- OK. Show 10:
Figure 10
Click the link and click Next:
Figure 11
Select the new project and click Add. The project appears in the right area and Finish.
Figure 12
Servers is configured, as shown in.
Figure 13
In the small Servers window, we can see one line: Tomcat v9.0 Server at localhost [Stopped, synchronized], double-click to configure, 08, and close this page after Configuration:
Figure 08
5. Set an alias for a website:
Right-click the Project -- Properties -- Web Project Settings -- enter the alias "Emp" -- OK
Figure 14
6. configure a welcome page for web. xml:
Add the following nodes:
<! -- Configure the default welcome page for the website -->
<Welcome-file-list>
<! --
When the user sends the following request
Http: // localhost: 8080/Emp
Tomcat configuration information, automatically pushes emp_add.html to the user's browser
-->
<Welcome-file> page/emp_Add.html </welcome-file>
</Welcome-file-list>
The meaning of the above node is to set the default homepage address.
7. Create a new file folder pageunder webcontentand click "emp_add.html" on the web page.
Last visit URL:
Http: // localhost: 8080/Emp/
Summary: This article applies to the first person who configures the javaee environment. This article does not involve servlet development knowledge.