加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Spring MVC – 无法为JSP编译类

发布时间:2020-12-15 02:14:36 所属栏目:Java 来源:网络整理
导读:我正在关注VirtualPairProgrammers的 Spring MVC课程,他们提供的工作空间似乎有些问题.运行代码时出现以下错误. org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 1 in the generated java file The type j
我正在关注VirtualPairProgrammers的 Spring MVC课程,他们提供的工作空间似乎有些问题.运行代码时出现以下错误.

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

出了什么问题?这是我的控制器中的代码:

@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上运行代码的简单案例.

我将通过VirtualPairProgrammers与您联系,当我们整理出版本不匹配时,我们将更新课程以使用Tomcat 8.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读