【问题标题】:Display a list by display:table tag in Spring + Hibernate MVC project在 Spring + Hibernate MVC 项目中通过 display:table 标签显示列表
【发布时间】:2015-12-29 08:43:24
【问题描述】:

我正在使用 netbean IDE 进行 MVC 项目,但在表格上显示我的对象时遇到问题 这是我的jsp页面

<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="model.Clothes"%>
<%@page import="org.hibernate.Session"%>
<%@page import="cfg.HibernateUtil"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="display" uri="http://displaytag.sf.net" %>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Clothes</title>
</head>
<body>
    <div style="margin-left: 10%; ">

        <%
            Session session1 = HibernateUtil.getSessionFactory().getCurrentSession();
            List<Clothes> clothes = new ArrayList<Clothes>();
            session1.beginTransaction();
            clothes = session1.createQuery("from Clothes").list();
            session1.getTransaction();
            System.out.println(clothes.size() + "aaaaaaaaa");
            session1.close();
            request.setAttribute("results", clothes);
        %>
        <display:table name="results" pagesize="10"/>
    </div>
    <jsp:include page="/index.htm" flush="true"/>
</body>

并且浏览器在包含'display'标签的行显示异常:“org.apache.jasper.JasperException:处理JSP页面/WEB-INF/jsp/clothes.jsp时发生异常”我在哪里做错了,请帮帮我,我是java web的新手。

p/s:我在我的项目中添加了库,它们是:displaytag-1.2、displaytag-export-poi-1.2、displaytag-portlet-1.2 和 commons-lang-2.6。

【问题讨论】:

  • 错误消息的其余部分,包含异常消息和堆栈跟踪,告诉您哪里出错了。红色吧。看不懂就贴出来。
  • 它返回 javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/commons/beanutils/NestedNullException java.lang.NoClassDefFoundError: ; org/apache/commons/beanutils/NestedNullException java.lang.ClassNotFoundException: ; org.apache.commons.beanutils.NestedNullException
  • 您缺少依赖项。阅读displaytag.org/1.2/displaytag/dependencies.html,或使用 Maven 或 gradle 为您解决依赖关系。
  • 你需要提交一个事务,你不需要它session1.getTransaction();
  • 在下面查看我的答案以获取解决方案!

标签: spring hibernate jsp spring-mvc displaytag


【解决方案1】:

我按照@JB Nizet 的说明进行操作,它起作用了,只需使用与此链接中列出的完全相同的库:http://www.displaytag.org/1.2/displaytag/dependencies.html 但是,在某些PC上,当使用org.slf4j时,您的项目无法正常工作,只需将它们从项目中删除即可!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-18
    • 2016-01-03
    • 2014-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多