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

来源:互联网 发布:冬天男鞋推荐知乎 编辑:程序博客网 时间:2024/05/16 18:36

今天,处理多语言标签的时候遇到了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 plaincopy
  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
原创粉丝点击