IDEA creates a JavaWeb project

1. Create a project

   ①, open IDEA

image


② Project name

image

    After clicking Finish, the project is successfully created, as shown below:

image

   Next, create two folders under WEB-INF in the web: classes and lib (where classes store the compiled class files and lib is used to store jar packages)

③, configure the class byte code file path

We click the imageicon in the operation bar , or File—> Project Structure (shortcut Ctrl + Alt + Shift + S), and then find Module.

image

Create a class file, and then set its storage path, or this interface.

image

After setting, the classes directory will turn orange.


④, configure the jar package storage path (lib folder),

Why do we configure the storage path of the jar package: it is because the jar package is directly copied to the created bin directory, the program will not be loaded into these packages when running, so we need to set it up.

First create a lib directory in WEB-INF, the creation method is the same as creating classes.

image

image

image

Then ok

image

   Then, a JavaWeb project is all configured.

2. Configuration items

The configuration project is to configure the JavaWeb project in the Tomcat server. I wrote an article about the configuration and use of Tomcat before . It is similar to that there, so I copied the pictures there.


Click Add Configuration in IDEA, or open the menu Run-> select Edit Configuration.

After the window pops up, click + , then slide down, and then select Local of Tomcat Server (if there is no Tomcat Server, click items more).

image

  After clicking Local, the following interface will appear:

image

  Note: Different IDEA versions may have different interfaces, but the general operation is the same. (My IDEA2018 model, I don't think it is necessary to pursue the latest version, the one that suits you is the best)

  The next step is to deploy and run the project in Tomcat. After we configure Tomcat, an interface will pop up under IDEA.

  Right-click Tomcat and select Artifacts, then add the project to it, and right-click Run.

image

image

  Or in Edit Configurations, select Deployment in the created Tomcat container, click the "+" sign on the right, and then select Artifact.

image

Then right-click Tomcat to run below, you can view the results in the browser.


3. Run the project

We modify the content of the index.jsp page and start Tomcat.

image


After running, the page will pop up automatically. If there is no pop up, manually enter localhost: 8080.

image

Guess you like

Origin www.cnblogs.com/tanghaorong/p/12731525.html