您可以创建一个常量配置参数,例如
<constant name="struts.result.path" value="/WEB-INF/classes" />
然后将此常量注入自定义
dispatcher结果。将此添加到默认包:
<result-types> <result-type name="dispatcher" default="true" /></result-types>
实现很容易,您只需在配置结果后在其位置添加前缀。
public class MyServletDispatcherResult extends ServletDispatcherResult { private String resultPath; public String getResultPath() { return resultPath; } @Inject(value = "struts.result.path", required = false) public void setResultPath(String resultPath) { this.resultPath = resultPath; } @Override public void setLocation(String location) { super.setLocation(resultPath+location); } public MyServletDispatcherResult() { super(); }// @Inject// public MyServletDispatcherResult(String location) {//// super(resultPath+location);// }}然后,您可以在结果中使用普通位置,例如
<result name="SUCCESS">/index.jsp</result>



