大家好!在使用<bean:message>标签时,遇到了如下的问题。<%@ page language="java" pageEncoding="utf-8"%><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %><html:html lang="true">
<body>
<html:link titleKey="title.info" forward="globalforward2">test international</html:link>
<bean:message key="title.info"/>
</body>
</html:html>运行该JSP页面,总是提示错误: java.lang.IllegalArgumentException: can't parse argument number Chinese疑惑的问题:
1、<html:link> 标签中的titleKey="title.info" ,可以正确找到对应资源文件的key问题:
在 <bean:message> 标签中的key = "title.info", 却找不到对应资源文件的key2、在struts-conf.xml中只配置了一个资源文件
<message-resources parameter="cn.softspeed.j2ee.struts.ApplicationResources" />所有资源文件部署在struts对应的包下:
ApplicationResources_en.properties 、ApplicationResources_zh_CN.properties 、ApplicationResources.properties问题:
没有在struts-conf.xml中配置 英文和中文的配置文件,但是修改浏览器的言语后, <html:link> 的titleKey属性可以找到对应的KEY ,但是 <bean:message> 却总是提示错误。
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %><html:html lang="true">
<body>
<html:link titleKey="title.info" forward="globalforward2">test international</html:link>
<bean:message key="title.info"/>
</body>
</html:html>运行该JSP页面,总是提示错误: java.lang.IllegalArgumentException: can't parse argument number Chinese疑惑的问题:
1、<html:link> 标签中的titleKey="title.info" ,可以正确找到对应资源文件的key问题:
在 <bean:message> 标签中的key = "title.info", 却找不到对应资源文件的key2、在struts-conf.xml中只配置了一个资源文件
<message-resources parameter="cn.softspeed.j2ee.struts.ApplicationResources" />所有资源文件部署在struts对应的包下:
ApplicationResources_en.properties 、ApplicationResources_zh_CN.properties 、ApplicationResources.properties问题:
没有在struts-conf.xml中配置 英文和中文的配置文件,但是修改浏览器的言语后, <html:link> 的titleKey属性可以找到对应的KEY ,但是 <bean:message> 却总是提示错误。
解决方案 »
- EJB3.0中,如何吧EJBQL语句转换为SQL语句
- 怎样用htmlparser取得标签对之间的内容?
- 怎么实现(struts标签html:select)既能下拉 又能输入?
- Weblogic 8.1 sp2英文版使用Ajaxanywhere不刷新,如何解决?
- 救命啊,一个非常麻烦的问题,请各位帮我解决一下啊,我的脑袋快爆炸了
- 请问,哪里有创建webservice的详细教程?
- 在oracle9i里用存储过程/函数返回多条记录
- 大家认为现在jboss最稳定,最快的是哪个版本
- 想学习OA,可是到哪里去找资料呀?
- 当class文件更新后,怎么样才能使weblogic不重新启动就可以执行新的class
- jfreechart画柱状图如何不显示负数
- 我从sqlsever2000中读取数据插入到mysql中,为啥插入不进去呢!
想了解更多可以搜索下
<%
Map mapCN = new HashMap();
mapCN.put("language","zh");
mapCN.put("country","CN");
mapCN.put("page","/locale.jsp");
request.setAttribute("mapCN",mapCN);
Map mapEN = new HashMap();
mapEN.put("language","en");
mapEN.put("country","US");
mapEN.put("page","/locale.jsp");
request.setAttribute("mapEN",mapEN);
%>
<body>
<html:link action="/locale" name="mapCN" titleKey="title.info" bundle="prompt" scope="request">Chinese</html:link><br>
<hr>
<bean:message key="title.info" bundle="prompt"/>
<html:link action="/locale" name="mapEN" titleKey="title.info" bundle="prompt" scope="request">English</html:link>
</body>
</html:html>4楼的兄弟,<bean:message property="title.info"> 则提示:
java.lang.NullPointerException: Null attribute name<bean:message key="title.info"> 则提示:
java.lang.NullPointerException: Null attribute name可以肯定当前session中的locale对象 和 资源文件都没问题,将代码中的<bean:message key="title.info" bundle="prompt"/>删除 。运行效果都是正常的。( <html:link> 鼠标移动的提示消息的国际化显示效果正常)出错的就是:<bean:message key="title.info" bundle="prompt"/> or <bean:message property="title.info" bundle="prompt"/>
先查查ApplicationResources_zh_CN.properties 有没有title.info,
因为:
<html:link action="/locale" name="mapCN" titleKey="title.info" bundle="prompt" scope="request">Chinese </html:link><html:link>标签正确的获得到key(title.info)对应的value(xxx)
只是<bean:message>标签没有获得。
你link标签可以得到,那么bean标签肯定也能得到。
我觉得这不是你的问题。可能是struts包体的问题,如果是1.1那么试验下struts1.3。也许就解决了。
The message key of the requested message, which must have a corresponding value in the message resources. If not specified, the key is obtained from the name and property attributes.这个是struts taglib 中对bean:message标签的参考文档的描述哦。
给大家散分吧 呵呵