1,displaytag页面的汉化:
把displaytag.properties考到项目里,同时复制一份displaytag.properties,修改文件名displaytag_zh_CN.properties,把文件里面的对应条目改成中文即可;
同时,文件里的对应两条配置注意选择合适的使用,下面是struts的配置
locale.provider=org.displaytag.localization.I18nStrutsAdapter
locale.resolver=org.displaytag.localization.I18nStrutsAdapter
2,excel导出中文内容乱码:
重载类org.displaytag.export.ExcelView,复写
- public String getMimeType(){
- return "application/vnd.ms-excel;charset=gb2312";
- }
原代码是
- public String getMimeType(){
- return "application/vnd.ms-excel";
- }
修改displaytag_zh_CN.properties中对应条目:
export.excel.class=yourpackage.SimpleChineseExcelView
3,Excel导出文件名中文乱码:
重载类org.displaytag.tags.SetPropertyTag,复写注意,这种解决方案只能解决value的中文名称,而不能解决bodycontent内的中文名称,如
<display:setproperty name="export.excel.filename">导出菜单.xls</display:setproperty>display:setProperty>
4,Excel导出文件名中文乱码bodycontent中的不完美解决方案
<display:setproperty name="export.excel.filename">
<!---->
</display:setproperty>
这种解决方案之所以称之为不完美适应为它要借助页面中的java代码实现
使用Mesources
- private String value;
- public void setValue(String propertyValue){
- try{
- this.value = new String(propertyValue.getBytes("GBK"),"ISO-8859-1");
- }catch(Exception e){
- this.value = propertyValue;
- }
- super.setValue(this.value);
- }
修改displaytag.tld对应条目
- private String value;
- public void setValue(String propertyValue){
- try{
- this.value = new String(propertyValue.getBytes("GBK"),"ISO-8859-1");
- }catch(Exception e){
- this.value = propertyValue;
- }
- super.setValue(this.value);
- }
修改displaytag.tld对应条目
xml 代码
- <name>setPropertyname>
-
- <tag-class>yourpackage.SimpleChineseSetPropertyTagtag-class>
在jsp中应用时
xml 代码
- <display:setProperty name="export.excel.filename" value="导出中文名称.xls"/>
<display:setproperty style="COLOR: rgb(255,0,255)" name="export.excel.filename">注意,这种解决方案只能解决value的中文名称,而不能解决bodycontent内的中文名称,如
导出菜单.xlsdisplay:setProperty></display:setproperty>
4,Excel导出文件名中文乱码bodycontent中的不完美解决方案
- <display:setProperty name="export.excel.filename">
- <%=new String("导出菜单.xls".getBytes("GBK"),"ISO-8859-1") %>
- display:setProperty>
这种解决方案之所以称之为不完美适应为它要借助页面中的java代码实现
使用Mesources
- <display:setProperty name="export.excel.filename">
- <%
- MessageResources mrs = (MessageResources)request.getAttribute("org.apache.struts.action.MESSAGE");
- String fileName = mrs.getMessage("menu.export.excel.filename");
- fileName = new String(fileName.getBytes("GBK"),"ISO-8859-1");
- out.print(fileName);
- %>
- display:setProperty>
分享到:
相关推荐
displaytag-1.1.1-execle@cvs导出中文乱码问题解决.jar
displaytag 表格 标签 displaytag-1.1.1标签库及其使用方法
displaytag源码大全,可直接部署,查看效果,案例齐全。
displaytag-export-poi-1.1.1
displaytag-1.1.1-api.chm
displaytag-examples-1.1.1.war 例子
分页标签, 分页标签, 分页标签,
Display tag library 1.1.1下载 用于表格美观显示需要的文件 displaytag-1.1.1-bin.zip 也可以自己到 http://sourceforge.net/project/showfiles.php?group_id=73068<br>直接下载
http://sourceforge.net这是个开源网站里面放的很多流行的开源软件希望大家多多去看。 displaytag 一个非常不错的分页标签等等。 这个包里有现成的例子,直接可以运行去看,还有用到的文档,希望对大家有帮助
displaytag-1.1.jar和display-export-poi-1.1.jar下载
displaytag-1.2.jar 显示标签
displaytag-export-poi-1.2.jar
针对displaytag Excel导出中文乱码的情况,对其添加gbk编码,使其能顺利将中文导出excel
displaytag-1.2-src.zip
displaytag-1.0-b3
displaytag-1.1.jar,显示表格的tag
displaytag1.1显示排序分页导出自动标签
从数据库获得数据,显示到页面。功能相当强大,支持直接生成excel等格式,支持排序等,但似乎不支持分页显示