首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

SSH2框架中配备struts2拦截器报错

2012-08-26 
SSH2框架中配置struts2拦截器报错严重: Exception starting filter struts2.2.1Unable to load configurat

SSH2框架中配置struts2拦截器报错
严重: Exception starting filter struts2.2.1
Unable to load configuration. - interceptor-ref - file:/D:/software/apache-tomcat-6.0.20-t/apache-tomcat-6.0.20/webapps/recommend/WEB-INF/classes/struts.xml:36:48
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
...
Caused by: Unable to load configuration. - interceptor-ref - file:/D:/software/apache-tomcat-6.0.20-t/apache-tomcat-6.0.20/webapps/recommend/WEB-INF/classes/struts.xml:36:48
... 20 more
Caused by: Unable to find interceptor class referenced by ref-name myInterceptor - interceptor-ref - file:/D:/software/apache-tomcat-6.0.20-t/apache-tomcat-6.0.20/webapps/recommend/WEB-INF/classes/struts.xml:36:48
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildInterceptorList(XmlConfigurationProvider.java:550)
... 22 more
2011-3-18 11:24:13 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2011-3-18 11:24:13 org.apache.catalina.core.StandardContext start
严重: Context [/recommend] startup failed due to previous errors
2011-3-18 11:24:13 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext

解决方案:
引起该错误的原因是拦截器的声明和引用没有配置在同一个package下
所以使用拦截器时一定要注意,拦截器的声明和引用必须配置在同一package下
如果如下配置,则一定会报出上述错误,因为拦截器声明在name为portal的package中,而拦截器的引用是在name为test的package中:
<struts>
<constant name="struts.objectFactory" value="spring" />
<include file="struts-default.xml"></include>
<package name="portal" extends="struts-default"> 
<interceptors>
<interceptor name="myInterceptor" type="chain">login</result>
</global-results>
        <action name="prepareUserIndex" method="prepareUserIndex">
        <interceptor-ref name="myInterceptor"></interceptor-ref>
        <result name="success">/WEB-INF/jsp/userIndex.jsp</result>
        </action>
        <action name="ajaxShowVisitedApps" method="showVisitedAppsInfo">
        <interceptor-ref name="myInterceptor"></interceptor-ref>
        <result name="success">/WEB-INF/jsp/visitedAppsInfo.jsp</result>
        </action>
    </package>
   <package name="test" extends="json-default">
    <action name="ajaxGetAppRemarkStatus" method="getAppRemarkStatus">
        <interceptor-ref name="myInterceptor1"></interceptor-ref>
        <result name="success" type="json">
<param name="root">isLiked</param>
</result>
        </action>
    </package>
</struts>

热点排行