“This is the fourth day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

preface

Hello everyone, I'm GW_gw. I'm glad to learn and progress with you.Copy the code

For beginners creating JavaWeb projects using IDEA is really clueless, like walking in the night.

This article will keep you from getting lost again!! Read on:

The following content is from the network, if there is any infringement, please contact me to delete, this article is only used for learning exchange, not for any commercial purposes.

Abstract

This article focuses on creating a JavaEE project using IDEACopy the code

Create JavaEE projects using IDEA

1. Create an empty project

Usually we need to create multiple projects within a project, so we create an empty project and create multiple modules within the project, i.e., multiple projects.

The specific steps are as follows:

2. Create a new module

Create a new module of Java Enterprise type and define it as Web Application. Select the Tomcat path (green version or installed version).

The specific process is as follows:

3. Write your own Servlet

Write a simple test code:

 import javax.servlet.*;
 import javax.servlet.http.*;
 import javax.servlet.annotation.*;
 import java.io.IOException;
 ​
 @WebServlet(name = "ServletTest", value = "/ServletTest")
 public class ServletTest extends HttpServlet {
     @Override
     protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
         System.out.println("Hello Servlet,I'm coming!");
     }
 }
 ​
Copy the code

Tomcat 4. Configuration

This already exists, maybe I’ve configured it before.

If not, use the following:

The Url is in the browser’s address: http://localhost:8080/Servlet01_war_exploded

The port number is 8080

5. Test run

When run, the default interface opens, which is the HelloServlet after the Module is created

How do you see yourself?

Add our value to the end of the previous screen.

View our output in Idea:

conclusion

This is how to create a JavaEE project using IDEA.