警告:在类型'org.apache.struts2.dispatcher.ServletRedirectResult'上设置属性时捕获OgnlException

时间:2013-12-28 05:49:55

标签: java configuration struts2 ognl actionresult

我找到this solution来解决这个警告,但即使我把这段代码从包中的链接,动作和struts标记中得到,也说无效标记。

<category name="com.opensymphony.xwork2.ObjectFactory">
   <priority value="fatal"/>
</category>

例外:

Dec 28, 2013 11:10:36 AM com.opensymphony.xwork2.util.OgnlUtil internalSetProperty
WARNING: Caught OgnlException while setting property 'reportType' on type 'org.apache.struts2.dispatcher.ServletRedirectResult'.
ognl.NoSuchPropertyException: org.apache.struts2.dispatcher.ServletRedirectResult.reportType

XML:

   <action name="gatherReportInfo" class="leo.struts.Redirect_Action">   
      <result name="showReportResult" type="redirect">
         <param name="location">/generateReport.jsp</param>
         <param name="reportType">pie</param>   
      </result>
   </action>

动作:

public String getReportType() {
        return reportType;
    }

    public void setReportType(String reportType) {
        this.reportType = reportType;
    }
}

1 个答案:

答案 0 :(得分:1)

结果类型"redirect"在类

中定义

org.apache.struts2.dispatcher.ServletRedirectResult

  

sendRedirect方法调用到指定的位置。响应   被告知将浏览器重定向到指定的位置(一个新的   来自客户的请求)。这样做的后果意味着   动作(动作实例,动作错误,字段错误等)   只是执行丢失,不再可用。这是因为行动   建立在单线程模型上。传递数据的唯一方法是   通过会话或网络参数(url?name=value)可以   是OGNL表达。

除非您没有通过定义具有相同名称的自定义结果类型来覆盖它。

bean配置结果不同,可以覆盖结果类型。但是,它不是,并且查看类docs,您可以确定它没有名为reportType的字段。结果你收到了警告。

如果从结果配置中删除此param,它将解决问题。