我在Struts 2中写了一些实现Struts 1功能的方法
支柱 1 ActionForward
:
new ActionForward("/home/ShowPage.do?page=edit",true);
我在 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:获取结果路径:
String url = mapping.findForward(result).getPath();
我在 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);
就像我在 Struts 2 中写了一些替代方法一样。
上述替代方法工作正常。但我需要知道,这些方法是否会在将来产生任何问题,或者我需要更改上述方法中的任何内容以实现与 Struts 1 中相同的效果。