Eclipse creates new projects and runs projects

1. New projects

1. Open Eclipse, File - New - Dynamic Web Project

2. Enter the project name and click Next.

3. Configure the storage directory for the project source files and classes files. The one shown here is [src\main\java], then the newly created project will not have [WebContent], which will not affect the project operation. Click Next.

Check [Generate web.xml deployment descriptor] and click Finish.

[Context root] is the access path of the project. When accessing the web project, the name following the port (used when accessing on the address bar), such as http://localhost:8080/MyDynamicWeb/index.html MyDynamicWeb;

[Content directory] is the root directory of the web application that is actually deployed to the Tomcat/webapp directory (actually existing in the file system).

After it is built, it looks like this:

If you want to specify the compilation path of the Java file (with WebContent), when performing this step as shown in the figure, select [src\main\java] and click Remove.

Then click Next.

Enter WebContent in [Content directory], check [Generate web.xml deployment descriptor], and click Finish.

After it is built, it looks like this:

2. Create a JSP page and run it

Click WebContent - New - JSP File

Name it [MyJSP.jsp] and click [Finish].

Write hello world in [MyJSP.jsp], save it with [Ctrl+S], and then run it.

First click the green run button in the upper left corner, select Tomcat in the pop-up page, and click Next.

The left is the working directory, the right is the deployment directory, the right is the project to be run, delete the others (if any), and click Finish.

If the operation is successful, the following page will appear:

There is another way to run:

Select [MyJSP.jsp], right-click Run As - Run on Server

The next steps are the same as the previous running method. Select Tomcat in the pop-up page and click Next... I will not go into details.

Guess you like

Origin blog.csdn.net/Eileennnnnn/article/details/133810933