Thanks Paul,
So based on what you said, I looked up creating a custom result type:
http://indreshtech.blogspot.com/2013/03/implementing-custom-resulttype-in.html
And added this code (struts.xml):
<result-types>
<result-type name="keyword-result-type"
class="example.framework.KeywordResultType"></result-type>
</result-types>
And using it like so (struts.xml):
<action name="Titles" class="example.application.TitlesAction"
method="execute">
<result type="keyword-result-type"
name="success">/HelloWorld.jsp</result>
</action>
In the output from these statements:
public class KeywordResultType implements Result {
public void execute(ActionInvocation actionInvocation) throws Exception {
System.out.println("result code="+actionInvocation.getResultCode());
System.out.println("result="+actionInvocation.getResult());
}
}
I'm getting:
result code=success
result=example.framework.KeywordResultType@12da22e9
So how can I get the actual JSP file (/HelloWorld.jsp) it is going to and
rewrite that rather than just "success"?
Chris
On Jul 1, 2014, at 5:12 PM, Paul Benedict <[email protected]> wrote:
> It sounds like what you want is to create a new result type.
>
>
> Cheers,
> Paul
>
>
> On Tue, Jul 1, 2014 at 4:08 PM, Christopher Gokey <[email protected]> wrote:
>
>> We've got some pretty old code that I'm trying to port over to Struts2 and
>> if someone could point me in the right direction in how I can rewrite this
>> code that we subclassed in Struts1's RequestProcessor to handle the same
>> type of thing in Struts2, I'd really appreciate it.
>>
>> Basically:
>>
>> 1) In Struts1, we implements a custom RequestProcessor, that overrides:
>>
>> public class CustomRequestProcessor extends RequestProcessor
>> protected void processForwardConfig(HttpServletRequest request,
>> HttpServletResponse response,
>> ForwardConfig forward) throws
>> IOException, ServletException
>>
>> 2) In the method above, it grabs the path:
>>
>> String path = forward.getPath();
>>
>> 3) If the path is a .jsp file, it does things special and rewrites where
>> the JSP file is located.
>> Then calls:
>>
>> newPath = determineNewPath(path);
>> doForward(newPath, request, response);
>>
>> I thought about overwriting StrutsPrepareAndExecuteFilter, but it isn't
>> obvious how I can grab the path and rewrite it, so any suggestions/help
>> would be greatly apprecicated. Is this something that an Interceptor
>> would be best in handling?
>>
>> Thanks,
>> Chris
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]