如题,这是配置:
  <constant name="struts.enable.DynamicMethodInvocation" value="true" />
    <constant name="struts.devMode" value="true" />    <package name="test" namespace="/" extends="struts-default">
     <interceptors>
         <interceptor name="a" class="ysgw/dave/myInterceptor/MyInterceptor"/>
        </interceptors>        <default-action-ref name="test" />        <global-results>
            <result name="error">/error.jsp</result>
        </global-results>        <global-exception-mappings>
            <exception-mapping exception="java.lang.Exception" result="error"/>
        </global-exception-mappings>
        
        
        
        <action name="test">
            <interceptor-ref name="a"/>
            <interceptor-ref name="defaultStack"/>
            <result> /TestInterceptor.jsp</result>
        </action>
        
     </package> 
这是拦截器代码:
package ysgw.dave.myInterceptor;import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;public class MyInterceptor extends AbstractInterceptor{ /**
 * 
 */
private static final long serialVersionUID = 1L;
@Override
public String intercept(ActionInvocation invocation) throws Exception {
long startTime = System.nanoTime();
System.out.println("start time : " + startTime);
String result = invocation.invoke();
long endTime = System.nanoTime();
System.out.println("end time : " + endTime);
System.out.println("time : " + (endTime - startTime));

return result;
}

}strutsinterceptor

解决方案 »

  1.   

    你ctrl +  点下 class属性配置
      

  2.   

    ysgw/dave/myInterceptor/MyInterceptor->ysgw.dave.myInterceptor.MyInterceptor
      

  3.   

    在web.xml中配置struts2的入口filter了吗?还有拦截器写的没问题,你再确定你访问的url没有问题?
      

  4.   

    struts.xml配置错误。应该把你自己的拦截器配置成拦截器,然再在action里面引用,
    <package name="default" extends="struts-default">
       <interceptors>
           <interceptor name="timer" class=".."/>
           <interceptor name="logger" class=".."/>
       </interceptors>   <action name="login"
          class="tutorial.Login">
            <interceptor-ref name="timer"/>
            <interceptor-ref name="logger"/>
             <result name="input">login.jsp</result>
             <result name="success"
                type="redirectAction">/secure/home</result>
       </action>
    </package>