操作一样把勾进行勾选找到webapp选项
下一步创建就行
创建好会有显示
目录结构其余的都需要自己手动补齐
有小蓝点的才是一个web项目,
如果上面都正确的话没有小蓝点
在你pom.xml右上角有一个刷新点一下应该就会出现(或等待一会)
把其余两个进行补齐:
maven工程servle实例之导入项目依赖的jar包
package com.example.day_24_maaven.servlet; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @WebServlet("/webServlet") public class MyServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, IOException { doGet(request, response); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, IOException { request.getRequestDispatcher("/hello.jsp").forward(request, response); } }
hello.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> hello maven </body> </html>
pom.xml <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> </dependency> <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api --> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> </dependency>
maven工程servlet实例之jar包冲突解决
标签:jar,maven,实例,import,servlet,javax From: https://www.cnblogs.com/agzq/p/17155368.html