惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 似水流年

html颜色代码对照表 - 似水流年 - 博客园 让jbuilder显示中文 mysql数据导入导出语句 如何去掉超链接的下划线 使用标记文件更新和查询数据库 用一个链接同时打开两个帧页 Tomcat配置之自订tomcat Tag File简介 JS控制显示表单个数 Jsp+javascript打造二级级联下拉菜单 让tomcat支持中文Url传递 JSP文件操作 用MYSQL中的加密函数来加密:PASSWORD() 转义字符\的替换 - 似水流年 - 博客园 jsp中取得当前绝对路径的方法 Jstl申明DateSource Jstl验证用户登录 jstl验证用户是否已登录 在调用删除页面是出现提示信息
DisplayTag应用实践
似水流年 · 2005-03-27 · via 博客园 - 似水流年

1.表格的显示格式,在css中定义;

css

Property Default Valid Values Description Can be set using file/setProperty
css.tr.even even any valid css class name css class automatically added to even rows yes/yes
css.tr.odd odd any valid css class name css class automatically added to odd rows yes/yes
css.th.sorted sorted any valid css class name css class automatically added to the header of sorted columns yes/yes
css.th.ascending order1 any valid css class name css class automatically added to the header of a column sorted is ascending order yes/yes
css.th.descending order2 any valid css class name css class automatically added to the header of a column sorted is descending order yes/yes
css.table none any valid css class name css class automatically added to the main table tag yes/yes
css.th.sortable none any valid css class name css class automatically added to any sortable column yes/yes

2.修改classes/org/displaytag/properties/TableTag.properties,使其符合自己的要求.

Generic

Property Default Valid Values Description Can be set using file/setProperty
basic.show.header true true, false Indicates if you want the header to appear at the top of the table, the header contains the column names, and any additional action banners that might be required (like paging, export, etc...) yes/yes
basic.empty.showtable false true, false Indicates if you want the table to show up also if the list is empty yes/yes
basic.msg.empty_list Nothing found to display Any string The message that is displayed if the list that this table is associated with is either null, or empty. Used only if basic.empty.showtable is false . yes/yes
basic.msg.empty_list_row <tr class="empty"><td colspan="{0}">Nothing found to display.</td></tr> Any string The message that is displayed into the first table row if the list that this table is associated with is either null, or empty. {0} is replaced with the total column number to generate a correct colspan. Used only if basic.empty.showtable is true . yes/yes
sort.amount page page, list Indicates if the full list should be sorted before paging or if the sorting only affects items in the current page. Default behaviour is to sort only items in the current page (first paging, then sorting). yes/no
export.banner <div class="exportlinks"> Export options: {0} </div> Any string in a message format with 1 placeholder Contains the string that is displayed in the table footer when the user indicates that they want to enable the export function. The placeholder is replaced with links to the various export formats that are support. yes/yes
export.banner.sepchar | Any string Used to separate the valid export type (typically would be a bar, a comma, or a dash). yes/yes
paging.banner.placement top top, bottom, both When the table tag has to show the header for paging through a long list, this option indicates where that header should be shown in relation to the table yes/yes
paging.banner.item_name item Any string What the various objects in the list being displayed should be referred to as (singular) yes/yes
paging.banner.items_name items Any string What the various objects in the list being displayed should be referred to as (plural) yes/yes
paging.banner.no_items_found <span class="pagebanner"> No {0} found. </span> Any string in a message format with 1 placeholder What is shown in the pagination header when no objects are available in the list to be displayed. The single placeholder is replaced with the name of the items in the list (plural) yes/yes
paging.banner.one_item_found <span class="pagebanner"> One {0} found. </span> Any string in a message format with 1 placeholder What is shown in the pagination header when one object is available in the list to be displayed. The single placeholder is replaced with the name of the items in the list (singular) yes/yes
paging.banner.all_items_found <span class="pagebanner"> {0} {1} found, displaying all {2}. </span> Any string in a message format with 3 placeholders What is shown in the pagination header when all the objects in the list are being shown. {0} and {2} are replaced with the number of objects in the list, {1} is replaced with the name of the items {plural} yes/yes
paging.banner.some_items_found <span class="pagebanner"> {0} {1} found, displaying {2} to {3}. </span> Any string What is shown in the pagination header when a partial list of the objects in the list are being shown. Parameters:
  • {0}: total number of objects in the list
  • {1}: name of the items (plural)
  • {2}: start index of the objects being shown
  • {3}: end index of the objects being shown
  • {4}: current page
  • {5}: total number of pages
yes/yes
paging.banner.group_size 8 Any reasonable number The number of pages to show in the header that this person can instantly jump to yes/yes
paging.banner.full <span class="pagelinks"> [<a href="{1}">First</a>/ <a href="{2}">Prev</a>] {0} [ <a href="{3}">Next</a>/ <a href="{4}">Last </a>]</span> What is shown in the pagination bar when there are more pages and the selected page is not the first or the last one. Parameters:
  • {0}: numbered pages list
  • {1}: link to the first page
  • {2}: link to the previous page
  • {3}: link to the next page
  • {4}: link to the last page
  • {5}: current page
  • {6}: total number of pages
yes/yes
paging.banner.first <span class="pagelinks"> [First/Prev] {0} [ <a href="{3}">Next</a>/ <a href="{4}">Last</a>] </span> What is shown in the pagination bar when the first page is being shown. Placeholders are the same as for paging.banner.full . yes/yes
paging.banner.last <span class="pagelinks">[ <a href="{1}">First</a>/ <a href="{2}">Prev</a>] {0} [Next/Last] </span> What is shown in the pagination bar when the last page is being shown. Placeholders are the same as for paging.banner.full . yes/yes
paging.banner.onepage <span class="pagelinks">{0}</span> What is shown in the pagination bar when only one page is returned. Placeholders are the same as for paging.banner.full . yes/yes
paging.banner.page.selected <strong>{0}</strong> selected page. {0} is replaced with the page number, {1} with the page url. yes/yes
paging.banner. page.link <a href="{1}" title="Go to page {0}">{0}</a> link to a page. {0} is replaced with the page number, {1} with the page url. yes/yes
paging.banner.page.separator , separator between pages yes/yes
factory.requestHelper org.displaytag.util.DefaultRequestHelperFactory Class name for a valid RequestHelperFactory implementation RequestHelperFactory to be used. You can replace the default one if you need to generate links with a different format (for example in portal applications). yes/no

详情http://displaytag.sourceforge.net/configuration.html
3.如果TableTag.properties中的相关项包含中文则在web页上会出现乱码,解决方法:下载源码
修改 org.displaytag.properties.TableProperties.java ,把

    private String getProperty(String key)
    {
      return this.properties.getProperty(key);
    }

改成
    private String getProperty(String key)
    {
        String s = null;
        try {
          s = new String(this.properties.getProperty(key).getBytes("8859_1"), "GBK");
        }catch(Exception e) {
          s = null;
        }
      return s;
    }
4.确保export正确的方法是在web.xml中配置filter:
<filter>
    <filter-name>ResponseOverrideFilter</filter-name>
    <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
</filter-mapping>
详倾参见http://displaytag.sourceforge.net/export.html
慎用这个filter,尤其是使用tomcat做服务器的朋友,它会使本来就存在的乱码问题更加杂乱,除非改改源码.
5.在jstl中获得数据的方法:

<sql:query var="query" dataSource="${bookdev}">
  select *  from ebook
</sql:query>

<display-el:table name="pageScope.query.rows" />
用<display-el:table name="${query.rows}" />好像不行;
6.要在外部引用数据,必须在display:table中定义一个id

<display-el:table name="pageScope.query.rows" id="item" >
  <display-el:column property="title" title="题名" group="1" sortable="true" headerClass="sortable"/>
  <display-el:column property="creator" title="作者" group="2" sortable="true" headerClass="sortable"/>
  <display-el:column property="format" title="格式"/>
  <display-el:column title="删除"><a href="delete.jsp?id=${item.Id}" target="_blank">删除</a></display-el:column>
</display-el:table>

7.问题:如果检索数据库带有中文的字段,在翻页时就查不到记录了?
  这个问题着实把我吓了一大条,因为工程马上就要完了,要是它出了问题,那.....
 好在displaytag比较成熟,用的人比较多,早就有人提出这个问题了,在网上查了一下,原来又是一个编码的问题:
"DisplayTag的默认的URL默认为上一次的URL,如果上一次的URL包含中文的话,则会被进行URLEncode,所以在翻页的时候,又会把进行了URLEncode后的数据再次进行URLEncode,所以翻页就没有数据,因为这部分功能被封装在DisplayTag中"
也提出了解决办法:在Tomcat的server.xml的Connector部分添加URIEncoding="GBK",
我试了,但是好像不管用,不知道是不是版本不同的缘故,我用的是jakarta-tomcat-5.0.27,应该是比较新的.
考虑到Tomcat5中对Post和Get请求不再采用相同的处理策略,
我把查询表单的form method 由原来的post改为get,翻页就没有问题了,不过这个方法好像蹩脚了点,只能暂时这样了.
在后来的实践中我才发现原来是配置了filter的缘故(见4.确保export正确的方法是在web.xml中配置filter),这个filter打乱了正常的编码.
下面是我的一些测试: (配置了export的filter后)
send.jsp:
<form action="receive.jsp?cs=1" method="POST">
  <input name="key" type="text" value="中文" />
  <input name="sb" value="submit" type="submit"/>
</form>
receive.jsp:cs=${param.cs};key=${param.key}
结果:cs=1,但key=????即使前面用了<%request.setCharacterEncoding("GBK"); %>也不行
只有用<% String key = new String(request.getParameter("key").getBytes("ISO-8859-1"));out.println(key);%>或类似的编码处理才能得到正确结果.
将send.jsp的form method改为get
结果:cs的值为null,key=中文
8.相关资源:
http://www.theserverside.com/news/thread.tss?thread_id=21861