lyl801013 发表于 2017-1-13 09:17:07

运行程序出现"cannot find message resources under key org.apache.struts.action.MESSAGE"

  今天运行程序遇到一个错误在这里做一下记录,不是什么麻烦很容易搞定,但是做个记录吧。
  2010-05-24 13:34:41,468 ERROR - ServletException in '/failinfo.jsp': javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
  org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
  对于Message Resources是这样的,还不是太懂,先记下吧;MessageResources消息资源是Struts框架定义的一组消息资源包,用来简化开发支持国际化的,开发者可以自由的将页面Title、Label Name、Error Messages等显示信息定义在不同的资源文件中,然后在jsp、java中调用显示,在需要更改语言时,只要更改应用的配置就可以实现调用不同的资源文件从而实现国际化。
  具体操作步骤:
   第一:在web.xml文件<web-app> <servlet>"把下面的内容放在这里"</servlet></web-app>中加入
    <init-param>
    <param-name>application</param-name>
    <param-value>ApplicationResources</param-value>
    </init-param>
  第二:在struts-config.xml中加入如下设置:
   <message-resources parameter="ApplicationResources"/>
    该设置最好放在:</action-mappings>"放到这里"</struts-config>
  第三:确保ApplicationResources.properties文件在你建立的WEB-INF\classes文件夹中。
  可以把applicationResources.properties放到classes文件夹下其它目录,例如:
  把ApplicationResources.properties放入WEB-INF\classes\mydir文件夹下。struts-config.xml中的设置必须改
     <message-resources parameter="mydir/ApplicationResources"/>
  
    第四:就可能是键值的问题,struts的资源文件也是可以分多资源文件配置的,比如配备是这样的
<message-resources parameter="ApplicationResources" key="myAppRes"/>      
   如果只有一个带key的资源文件,那就会抛出 org.apache.struts.action.MESSAGE错误了,删除key即可。
 
参考资料:http://www.cnblogs.com/tjsquall/archive/2008/11/27/1342258.html
http://hi.baidu.com/luhui32599/blog/item/3373941ec11ab7fde0fe0bbf.html
页: [1]
查看完整版本: 运行程序出现"cannot find message resources under key org.apache.struts.action.MESSAGE"