Spring MVC - 无法为JSP编译类 [英] Spring MVC - Unable to compile class for JSP
问题描述
我正在关注VirtualPairProgrammers的Spring MVC课程,他们提供的工作空间似乎有些问题。运行代码时出现以下错误。
I'm following the Spring MVC course from VirtualPairProgrammers and the workspace they have provided seems to have some issues. I'm getting the following error when I run the code.
org.apache.jasper.JasperException:无法为JSP编译类:
生成的java文件中的行:1处发生错误
无法解析java.io.ObjectInputStream类型。它是从所需的.class文件间接引用的。
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
任何想法出了什么问题?这是我的控制器中的代码:
Any ideas what is going wrong? This is the code in my controller:
@RequestMapping("/viewAllBooks")
public ModelAndView viewAllBooks()
{
List<Book> allBooks = bookService.getEntireCatalogue();
return new ModelAndView("/displayAllBooks.jsp","allBooks",allBooks);
}
这是JSP文件:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
<title>All books for our store</title>
<link href="styles.css" rel="Stylesheet" type="text/css"/>
</head>
<body>
<jsp:include page="/web/header.jsp"/>
<div id="books">
<ul>
<c:forEach items="${allBooks}" var="nextBook">
<li>
<h2>${nextBook.title}</h2>
<p>
<span> by ${nextBook.author}
<fmt:formatNumber value="${nextBook.price}"
type="currency"
currencyCode="USD" />
<form method='post' action='<c:url value=""/>'>
<input type='hidden' name='id' value='${nextBook.id}'/>
<input type='image' src='cart-button.png'/>
</form>
</span>
</p>
</li>
</c:forEach>
</ul>
</div>
<jsp:include page="/web/footer.jsp"/>
</body>
</html>
推荐答案
我设计的课程让我能够提供帮助。我们提供了一份在录制时最新的Tomcat副本,这已经好几年了。但是Java 8在这个版本上打破了。这应该是在Tomcat 8上运行代码的一个简单例子。
I designed the course so I should be able to help. We supply a copy of Tomcat that was current at the time of recording, and this has been ok for a number of years. However Java 8 breaks on this version. It should be a simple case of running the code on Tomcat 8.
我会通过VirtualPairProgrammers与您联系,当我们整理出版本不匹配时,我们会更新使用Tomcat 8的课程。
I'll contact you through VirtualPairProgrammers and when we've sorted out the version mismatch we'll update the course to use Tomcat 8.
这篇关于Spring MVC - 无法为JSP编译类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!