struts升级到最高版本后遇到的问题。关于actionmessage传递问题。

Struts2升级到最新版本遇到的一些问题

首先是更换对应的jar,如asm、common、ongl、struts等等。更换后发现系统启动不了,按照网上的介绍,先后又更新了slf4j-log4j12-1.6.1.jar和cglib-2.2.2.jar后,起来了,但运行系统报错:NoSuchMethodError ...context.get(Object),修改web.xml,去掉struts-cleanup和FilterDispatcher,换上StrutsPrepareAndExecuteFilter,运行起来了。

仔细检查发现ongl对get和set的验证比原来严格了,比如原来action里有个变量aMap,方法getaMap()和setaMap()原来能用,现在就不能用了,必须改成getAMap()和setAMap().另外ongl原来允许set和get基本类型int,long等,升级后不再允许了,必须改成Integer、Long等对象类型。

另外遇到的一个问题就是原来有个action的result类型是chain,从前一个action将actionMessage带到下一个action,升级后发现带过来的actionMessage是null,google struts2 result chain actionMessage发现有高人遇到过这个问题,粘贴答案如下:
在网上查询N久,未解决。
一说必须使用 chain Result,我就是用的这个啊。
一说必须使用 chain Interceptor,我用的是 defaultStack,应该默认就有。
一说是需要使用 store Interceptor,感觉不对。
后在 ChainInterceptor 的 JavaDoc 中找到

引用


QUOTE:
By default Errors, Field errors and Message aren't copied during chaining, to change the behaviour you can specify the below three constants in struts.properties or struts.xml:
struts.xwork.chaining.copyErrors - set to true to copy Action Errors
struts.xwork.chaining.copyFieldErrors - set to true to copy Field Errors
struts.xwork.chaining.copyMessages - set to true to copy Action Messages

翻译后:

默认情况错误,现场错误和消息不会被复制在链接过程中,要改变行为您可以指定struts.propertiesstruts.xml中下面三个常量
struts.xwork.chaining.copyErrors - 设置为true,复制操作错误
struts.xwork.chaining.copyFieldErrors - 设置为true,复制字段错误
struts.xwork.chaining.copyMessages - 设置为true,复制行动消息

 

posted @ 2013-07-10 11:29  坚固66  阅读(224)  评论(0编辑  收藏  举报