Cannot find message resources under key org.apache.struts.action.MESSAGE

  http://fishyych.javaeye.com/blog/78581

struts出现org.apache.struts.action.MESSAGE异常的解决

关键字: struts, bean:write

使用struts的tag 的时候,当对象的属性值为long的时候,会报出如下的错误:

java 代码
  1. org.apache.jasper.JasperException: Cannot find message resources under key org.apache.struts.action.MESSAGE   
  2.     org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)   

查找了很多资料,解决的方法非常有意思,在struts-config.xml中添加如下的配置:

xml 代码
  1. <message-resources parameter="ApplicationResources"/>  

 

Struts时遇到的问题:

 

运行程序出现Cannot find message resources under key org.apache.struts.action.MESSAGE错误,是说明找不到ApplicationResources.properties,要注意以下四方面。

  第一:在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即可。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值