struts国际化操作中遇到display标签的处理办法

今天,处理多语言标签的时候遇到了display标签,记录一下最终的解决思路。

============================在本地搭建测试环境=================

先到display标签的官网http://displaytag.sourceforge.net/1.2/#display-el:table上把jar包下下来。然后按照install上的步骤应该就能成功导入display标签。

然后我还需要用到el表达式

所以要加这一句话才能是el表达式有效 <%@ page isELIgnored="false" %>

然后还需要用到jstl中的c标签。。

在这里可以找到下载地址http://download.csdn.net/detail/czxt0605/7671781 也可以在官网下载。

具体方法可以参照这个博客

http://blog.csdn.net/czxt0605/article/details/38080495

=====================

Eclipse中直接使用jstl标签,会出现如下错误


而在 Myeclipse中新建web工程,新建jsp页面可以直接使用jstl标签,因为在新建工程时Myeclipse自动导入了使用jstl所需的jar包。在Eclipse中使用jstl,需要:

1、导入jstl.jar、standard.jar 2个jar包;

2、在WEB-INF下拷入c.tld文件;

3、web.xml加上如下配置

[html]  view plain copy
  1. <jsp-config>  
  2.       <taglib>  
  3.           <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>  
  4.           <taglib-location>/WEB-INF/c.tld</taglib-location>  
  5.       </taglib>  
  6.   </jsp-config>  

经过这几步就可以正常使用jstl标签了

jar包下载地址:点击打开链接


=================



大致上是按照上述操作的,中间也式了其他的方法,eclipse崩贵几次。。。

============================结束在本地搭建测试环境=================

然后按照下面的代码就可以搞定了

资源文件还是用之前的message就可以了。

测试代码

<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false" %>
<br>
<%
 String [] test = new String[3];
 request.setAttribute("testMy", test);
%>
<c:set var="id1"><bean:message key = "label.select"/></c:set>
<c:set var="id2"><bean:message key = "label.chinese"/></c:set>
<c:set var="id3"><bean:message key = "label.english"/></c:set>
<display:table name = "testMy">
<display:column title = "${id1}" >1</display:column>
<display:column title = "${id2}" >2</display:column>
<display:column title = "${id3}" >3</display:column>
</display:table>


参考

http://blog.csdn.net/czxt0605/article/details/38080495


http://forum.mentaframework.org/posts/list/2279.page


http://forum.mentaframework.org/posts/list/1111.page

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值