栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在jsp页面中显示的页面明智结果

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在jsp页面中显示的页面明智结果

您可以使用displaytag

显示标签库是自定义标签的开源套件,提供了可在MVC模型中工作的高级Web呈现模式。该库提供了大量功能,同时仍易于使用。

您需要从此网站上下载jar
displaytag-1.2.jar

使用显示标签,您可以导出各种格式的数据,例如Excel,PDF等。
只需点击列名链接即可进行列排序。

网站http://displaytag.org上有很多示例

JSP代码:

<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>

有两种方法可以在JSP中获得列表 :1)使用jstl :(推荐)

只需使用

sql:query
标记并将结果以这种方式传递到表格标记

    <sql:query var="results">      select * from table    </sql:query>    <display:table name="${results.rows}" />    (or    <display:table name="pageScope.results.rows" />    if not using the EL version)

2)使用dynabeans

<%  Connection con = ...; // just open a connection  Statement stmt = con.createStatement();  ResultSet rs = stmt.executeQuery("SELECt * from table");  RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);  stmt.close();  con.close();  request.setAttribute("results", resultSet);%>  <display:table name="requestScope.results.rows" />

您可以使用任何一种方法,但建议首先使用JSTL。

您可以使用

sessionScope

  <display:table id="deviceDetailsID" name="sessionScope.overspeeddetails" pagesize="10" >    <display:column property="deviceID" title="Device ID" sortable="true" headerClass="sortable" />    <display:column property="TIMESTAMP" title="TIMESTAMP" sortable="true" headerClass="sortable" format="{0,date,dd-MM-yyyy}"/>    <display:column property="speed" title="Speed" sortable="true"/>    <display:column property="statuspre" title="Status Code"/>    <display:column property="address" title="Address" sortable="true" headerClass="sortable" /></display:table>

要在类路径和JSP上 使用

<sql:query>
添加JSTL1.2 jar

<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>

您需要在类路径中添加Commons Lang 2.6
jar以避免这种情况

java.lang.ClassNotFoundException:org.apache.commons.lang.UnhandledException



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/386512.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号