gpt4 book ai didi

java - 警告 : Caught OgnlException while setting property on type 'org.apache.struts2.dispatcher.ServletRedirectResult'

转载 作者:行者123 更新时间:2023-11-30 11:24:09 28 4
gpt4 key购买 nike

我找到了 this solution来解决这个警告,但即使我把这段代码放在包、 Action 和 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>

Action :

public String getReportType() {
return reportType;
}

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

最佳答案

结果类型"redirect"在类中定义

org.apache.struts2.dispatcher.ServletRedirectResult

Calls the sendRedirect method to the location specified. The response is told to redirect the browser to the specified location (a new request from the client). The consequence of doing this means that the action (action instance, action errors, field errors, etc.) that was just executed is lost and no longer available. This is because actions are built on a single-thread model. The only way to pass data is through the session or with web parameters (url?name=value) which can be OGNL expressions.

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

bean 不同,配置结果类型可以被覆盖。但是,事实并非如此,看看类 docs您可以确定它没有名为 reportType 的字段。结果你得到了那个警告。

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

关于java - 警告 : Caught OgnlException while setting property on type 'org.apache.struts2.dispatcher.ServletRedirectResult' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20811494/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com