我正在尝试使用注释和maven设置我的第一个struts 2应用程序。我正在关注这个例子struts2 annotations example
当我尝试在tomcat服务器7上运行应用程序时,我得到了这个异常
Grave: Exception startin filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter. StrutsPrepareAndExecuteFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
avr. 14, 2014 10:40:05 AM org.apache.catalina.core.StandardContext startInternal
Grave: Error filterStart
avr. 14, 2014 10:40:05 AM org.apache.catalina.core.StandardContext startInternal
Grave: Erreur de démarrage du contexte [/StrutsAnnotationsExample] suite aux erreurs précédentes
avr. 14, 2014 10:40:05 AM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["http-bio-8080"]
avr. 14, 2014 10:40:05 AM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["ajp-bio-8009"]
avr. 14, 2014 10:40:05 AM org.apache.catalina.startup.Catalina start
Infos: Server startup in 991 ms
任何人都可以帮助或告诉我缺少什么吗?
答案 0 :(得分:1)
看起来像是从教程中获取的代码中的拼写错误。在web.xml
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
答案 1 :(得分:0)
看起来教程中提供的示例示例缺少必需的jar文件。下载所有必需的jar并将它们放在WEB-INF / lib下。