I have wrote some methods to achieve Struts 1 functions in Struts 2
Struts 1 ActionForward
:
new ActionForward("/home/ShowPage.do?page=edit",true);
Same I did in Struts 2:
public String myActionForward(String url,boolean isRedirect) throws Exception
{
if(isRedirect){
response.sendRedirect(url);
}else{
RequestDispatcher rd = request.getRequestDispatcher(url);
rd.forward(request, response);
}
return null;
}
myActionForward("/home/ShowPage.do?page=edit",true);
Struts 1: To get result path:
String url = mapping.findForward(result).getPath();
Same I did in Struts 2:
public String myGetPath(String result) throws Exception
{
Map<String,ResultConfig> results = ActionContext.getContext().getActionInvocation().getProxy().getConfig().getResults();
ResultConfig rc = results.get(result);
String path = rc.getParams().get("location");
return path;
}
String url = myGetPath(result);
Like that I have wrote some alternative methods in Struts 2.
The above alternative methods are working fine. But I need to know, are these methods make any problem in future or I need to change anything in above methods to achieve the same as in Struts 1.