Java struts拦截器运行两次
我刚刚创建了一些struts拦截器Java struts拦截器运行两次,java,struts2,interceptor,Java,Struts2,Interceptor,我刚刚创建了一些struts拦截器 <interceptors> <interceptor name="alertableActionInterceptor" class="com.mycompany.web.interceptor.AlertableActionInterceptor" /> <interceptor-stack name="eposWebAuditStack"> <int
<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>
我添加了一些print语句,以表明当我点击healthCheck.action url时,拦截器似乎会执行两次,即使我只点击了一次url
有人能帮我解释为什么会发生这种事吗
我在这里添加了一个屏幕截图,显示firebug中的http请求。这里看起来好像有一个根请求,然后是一个后续的子请求(加倍)。我读对了吗?如果是这样的话,看起来我的http请求不知何故被加倍了
下面是jsp的外观
(包括1)
(包括2)
(包括3--内容)当你说两遍时,是在调用操作之前还是之后?信息不够。哪个拦截器,什么时候,为什么,发生了什么?请发布更多信息和拦截代码。需要更多详细信息;是什么让你认为它运行了两次——日志语句?你确定没有两个请求吗?没有理由一个拦截器会为一个请求任意运行两次。对不起,伙计们。我没有添加足够的信息,但我现在添加了更多信息。1)在发布评论时,最好使用@dudesname提醒这个家伙,否则他不会知道你做了什么;2) 避免使用scriptlets 3)尝试删除
4)尝试删除javascript函数设置位置。href 5)lol@ie sucks.css
:P
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;
}