struts2中使用@InterceptorRef注解时报错,找不到自定义拦截器

十里桃花不如你 2016-11-26 11:07:58
-----------------------------struts.xml中的配置--------------------------------------
<struts>
<package name="crm" extends="struts-default" namespace="/">
<interceptors>
<interceptor name="userInterceptor" class="com.itheima.interceptor.UserInterceptor"/>

<interceptor-stack name="myStack">
<interceptor-ref name="userInterceptor"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>

</interceptors>
</package>
</struts>


@Controller("visitAction")
@Scope("prototype")
@Namespace("/")
@ParentPackage("struts-default")
@InterceptorRef("myStack")
public class VisitAction extends BaseAction implements ModelDriven<Visit>{}


启动服务时报错:

Caused by: Unable to load configuration. - [unknown location]

at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479)
... 14 more
Caused by: Unable to find interceptor class referenced by ref-name userInterceptor - [unknown location]
...全文
409 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
huiwang188 2017-12-30
  • 打赏
  • 举报
回复
Action注解中的@ParentPackage("struts-default")参数要与struts.xml <package name="crm" 包名改一致即可
「已注销」 2016-11-27
  • 打赏
  • 举报
回复
「已注销」 2016-11-27
  • 打赏
  • 举报
回复
@ParentPackage("struts-default")
改为
@ParentPackage("crm")
即可。
--> com.opensymphony.xwork2.config.entities.PackageConfig

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧