大家好!在使用<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> 却总是提示错误。

解决方案 »

  1.   

    建议LZ用struts2标签,因为支持国际化。
    想了解更多可以搜索下
      

  2.   

    <bean:message> 标签用 property属性。<bean:message property = "title.info" />
      

  3.   

    请看清楚,楼主要的是struts1.。。
      

  4.   

      </head>
      <%
       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"/>
      

  5.   

    既然报java.lang.NullPointerException: Null attribute name 
    先查查ApplicationResources_zh_CN.properties 有没有title.info,
      

  6.   

    资源文件是没有问题的。
    因为:
    <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>标签没有获得。
      

  7.   

    真奇怪了,理论上是可以的。
    你link标签可以得到,那么bean标签肯定也能得到。
    我觉得这不是你的问题。可能是struts包体的问题,如果是1.1那么试验下struts1.3。也许就解决了。
      

  8.   

    <bean:message>这个没有key属性的吧,好像有property
      

  9.   

    key 
    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标签的参考文档的描述哦。
      

  10.   

    等了那么久没有解决问题,算了只能用jstl标签去做国际化。
    给大家散分吧 呵呵