我刚刚创建了一些struts拦截器。
<interceptors>
<interceptor name="alertableActionInterceptor" class="com.mycompany.web.interceptor.AlertableActionInterceptor" />
<interceptor-stack name="eposWebAuditStack">
<interceptor-ref name="alertableActionInterceptor"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<action name="healthCheck"
class="com.mycompany.web.action.HealthCheckAction"
method="input">
<interceptor-ref name="eposWebAuditStack"/>
<result name="input" type="tiles">page.healthCheck</result>
</action>
这就是我的拦截器的样子。
public class AlertableActionInterceptor extends AbstractInterceptor {
private static final long serialVersionUID = 3149079243463745381L;
/* (non-Javadoc)
* @see com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
*/
@Override
public String intercept(ActionInvocation invocation) throws Exception {
System.out.println("Running Inteceptor" + new Date());
/* pre-processing */
final ActionContext context = invocation.getInvocationContext();
HttpServletRequest request = (HttpServletRequest) context.get(StrutsStatics.HTTP_REQUEST);
/* call action */
String result = invocation.invoke();
boolean doLogic = Boolean.valueOf(updateNotifications);
if (doLogic){
System.out.println("Running Inteceptor with doLogicFlag");
}
return result;
}
我添加了一些打印语句来表明当我点击我的healthCheck.action网址时,拦截器似乎执行了两次,即使我点击了Url一次。
有人可以帮我解释为什么会这样吗?
我在这里添加了一个屏幕截图,显示了firebug中的http请求。它在这里看起来好像有一个root请求然后是一个后续子请求(加倍)。我看对了吗?如果是这样,我的http请求会以某种方式加倍。
这是jsp的样子......
http://pastebin.com/Thv0rNLY(包括1)
http://pastebin.com/8PyueWkf(包括2)
http://pastebin.com/UweqAbp5(包括3 - 内容)