赞
踩
最近在构建maven-web项目过程中发现一点问题:
调用servlet出现HTTP Status 500 错误
tomcat10之后,javax.servlet更名为jakarta.servlet,所以写成javax.servlet,tomcat就无法找到servlet依赖的类。
这里提供两种解决方法
将pom.xml
中servlet的dependency
改为
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
<dependency>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
可以将部署服务器由tomcat10
改为tomcat9
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。