MAVEN 新建Servlet类 找不到 javax.servlet.annotation.WebServlet

问题:

原依赖:

<!--pom.xml-->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>

解决方法:

1.添加Tomcat支持(tamcat lib目录中servlet-api.jar包的支持)

然后选择配置好的Tomcat即可。

2.添加MAVEN依赖

去掉了servlet-api的依赖,添加 javax.servlet-api

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>

原文地址:https://www.cnblogs.com/lanyi77/p/8203159.html

时间: 2024-10-12 08:35:19

MAVEN 新建Servlet类 找不到 javax.servlet.annotation.WebServlet的相关文章

maven新建web项目提示The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path

在pom.xml中添加下面代码来下载servlet-api: <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency>

Eclipse新建web项目出现The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path

Eclipse新建web项目出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 新建web项目后都,jsp页面顶端出现"红色"的报错信息:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path,经过仔细查看,原来是

解决IDEA找不到javax.servlet.jar包的问题

解决IDEA找不到javax.servlet.jar包的问题 配置完tomcat,准备照着资料实现Servlet接口,发现IDEA中并不能找到javax.servlet.jar包,一番查找之后,解决了问题,解决方法如下: 一.右键点击项目,选择Open Module Settings. 二.选择Libraries,点击加号+,选择Java. 三.浏览目录,找到tomcat安装目录下的lib里的servlet-api.jar包,点击ok. 四.最后选择项目即可. 原文地址:https://www.

HTTP Status 500 - javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/LoopTag

我在项目中导入了jar,还是不能使用EL表达式,一运行就出现了下面的额错误: org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/LoopTag org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWra

在Eclipse中编写servlet时出现"The import javax.servlet cannot be resolved" 问题解决办法

方法1:在Eclipse中,右击项目,选择Java Build Path->Libraries->Add External JARs,找到你计算机中tomcat的安装路径,在common\lib文件夹下选中"servlet-api.jar",添加点击"确定",ok! 方法2:把servlet-api.jar拖进工程里面,然后在servlet-api.jar上点右键--Build path--Add to build path,把项目refresh就可以了

maven 项目提示找不到javax.servlet.xxx问题解决

最近项目中需要用到javax.servlet.http.HttpServletRequest类,发现IDEA默认的没jar包,尝试了以下解决办法: 1. 直接在项目里的libraries里面添加servlet-api.jar和jsp-api.jar的话虽然不提示错误了,但是MAVEN编译的时候提示找不到类 2. 在ClassPath里添加对servlet-api.jar和jsp-api.jar的引用,效果同1 3. maven中增加以下依赖 <dependency> <groupId&g

新建maven工程使用webapp插件弹出javax.servlet.http.HttpServlet was not found on the Java Build Path异常

检查pom.xml文件中是否引用javax.servlet,引用如下所示:

Maven项目报错:The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path

刚刚新建完Maven项目,一般都会报这个错误,原因是没有默认添加需要的javax.servelet的jar包,所以打开pom.xml文件添加如下dependency即可: <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency>

新建 jsp异常,The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path

新项目,新建jsp页面的时候报异常: Multiple annotations found at this line: - The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path - The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 右