我用gb.department_name出现错误
javax.servlet.ServletException: Missing message for key gb.department_name

解决方案 »

  1.   

    这个properties文件和CLASS文件在一个包里,是放在这里的吗?
      

  2.   

    properties文件放哪了?要和配置文件中的对应起来。struts1.0.2最为actionServlet的一个参数(在web.xml中),struts1.1在struts-config.xml中设置: <message-resources parameter="ApplicationResources"/>
    如果不在classes根目录下,就要加上包名**.**.ApplicationResources
      

  3.   

    我用的是struts1.1,struts-config.xml为
    <struts-config> 
    <!--  ==========  Form  Bean  Definitions  ===================================  --> 
    <form-beans> 
    <form-bean  name="loginform"  type="test.LoginForm"/>
    <form-bean  name="DepartmentLoginFormBean"  type="name.huangbo.oa.rlzy.LoginForm"/>  
    </form-beans> 

    <!--  ==========  Action  Mapping  Definitions  ==============================  --> 
    <action-mappings> 
    <action path="/rlzy/DepartmentLogin" type="oa.rlzy.LoginAction" name="DepartmentLoginFormBean" scope="request" validate="false"> 
    <forward name="success" path="/rlzy/success.jsp"/> 
    <forward name="failed" path="/rlzy/failed.jsp"/> 
    </action> 
    </action-mappings> 

    <message-resources parameter="ApplicationResources"/></struts-config> 
    我把properties文件放在了classes下,可是启动TOMCAT报解析错误
      

  4.   

    名字是否一致?要不就是这个文件的编码问题,最好把它存为ansi。或者是文件的后缀是properties还是.txt,用记事本的话,不选择的话默认是.txt.
      

  5.   

    ApplicationResources.properties的名字和存放路径都没有错的,可现在解析还是那样的错误
      

  6.   

    看看是不是这个问题:
       你在资源文件里用了中文,所以应该把资源文件名改为:ApplicationResources_zh_CN.properties
      

  7.   

    llsoft(天堂鱼) 感谢你的指点,我的ApplicationResources.properties里确实有中文,但是我改为ApplicationResources_zh_CN.properties可还是不行,然后我把中文去掉了,启动的时候还是解析的错误。
    错误提示是:
    parse error at line 27 column 55:Element type "message-resoutces" must be declared
    parse error at line 27 column 55:Attribute "parameter" must be declared for element type "message-resoutces" 
    parse error at line 29 column 17:The content of element type "struts-config" must match "(data-sources?,form-beans?,global-forwards?,action-mappings?)"
      

  8.   

    struts的确是个比较麻烦的东西`~我搞了很长时间才配好
      

  9.   

    大哥!仔细点!
    parse error at line 27 column 55:Element type "message-resoutces" 
                                                                ^  
    must be declared
    parse error at line 27 column 55:Attribute "parameter" must be declared for element type "message-resoutces" 
                                            ^
    这里的resource写错了!!
    可不要这样说struts的坏话。其实,它是很不错的,也不难搞定。只是还不太了解。
    不过最近,我也碰到了一个资源文件的问题:
      在jsp页面中用<bean:message key="***"/>显示资源文件里的中文时,已经解析出来了,但是非要重新在IE里选一下gb2312才行.若是在页面中加上
    <%@ page contentType="text/html;charset=gb2312"%>,结果显示乱码,再在浏览器上怎么选,也出不来汉字了!!!
      

  10.   

    to llsoft(天堂鱼)
    不行的,我改为message-resoutce也是不行
      

  11.   

    Define your resource file at web.xml
    not struts-config.xml
    specify the full qualified class name. it should work
      

  12.   

    楼上的:
         可以在struts-config.xml中的定义的,从struts1.1b1开始就可以了。
    to  ggzzkk(Blue)              :
      再好好检查一下吧,要不你就用native2ascii(jdk\bin下的)转一下码。
    “我改为message-resoutce也是不行”,应该为:message-resource吧?
      

  13.   

    to llsoft(天堂鱼) 
    对不起,是笔误,我在struts-config.xml里面是message-resource
    我用了native2ascii ApplicationResources.properties转换这个文件,但问题还是没有解决啊