WARNING: Caught OgnlException while setting property on type 'org.apache.struts2.dispatcher.ServletRedirectResult'

StackOverflow https://stackoverflow.com/questions/20811494

Domanda

I found this solution to solve this warning but even if I put this piece of code I got from link in package,action and struts tag it says invalid tag.

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

Exception:

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;
    }
}
È stato utile?

Soluzione

Result type "redirect" is defined in the class

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.

Unless you didn't override it by defining a custom result type with the same name.

Unlike the bean configuration result types could be overridden. But, it's not, and looking at the class docs you can determine that it doesn't have a field named reportType. As a result you got that warning.

If you remove this param from the result configuration it'll solve the problem.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top