maven项目中jsp不能编译情况(Unable to compile class for JSP)

在maven项目中访问jsp页面的时候,有的时候会出现下面的这种情况:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 1 in the generated java file

The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

首先的话你需要看下是否加入了下面这两个依赖,没加的话加上去

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


再就是若你配置了tomcat插件如下:

<build>
<plugins>
<!-- 配置Tomcat插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<path>/</path>
<port>8082</port>
</configuration>
</plugin>
</plugins>
</build>

改了还是出现上面那个异常的话你可以看下你在Run as中的Maven build中输入的命令是否直接是tomcat:run这个命令,是的话可以改下命令为tomcat+你配置的tomcat的版本的版本号,例如你配置的是tomcat7的话那么你就可以将命令改成tomcat7:run

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值