java - struts2找不到类文件
高洛峰
高洛峰 2017-04-18 10:51:11
0
3
807

刚学到struts2这块,按照书上的代码观察struts2的action的运行情况,然后也是按照书上的步骤,先是导入包,然后配置web.xml和在src文件夹中配置一个struts.xml,最后编写一个index.jsp和first.jsp,然而在运行时候出了错误,报错情况为:
严重: Exception starting filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
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:4958)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5652)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

尝试解决过程:
网上查找过问题,有的答案说是有可能是包重复了?然后我根据这种做法重新导入了jar包,可是依然报错,然后还有的解决方案是说看下struts.xml和web.xml,看看是否有拼写错误或其它小问题,可是我观察了好久,没有看到出错的地方。
以下是我的页面出错情况、项目文件,以及配置情况:



希望路过的大佬能指教下,小弟感激不尽...

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
左手右手慢动作

The problem has been solved.
1. The specified page cannot be found
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
The solution is: <filter-class>org.apache.struts2.dispatcher.ng.filter The class path in .StrutsPrepareAndExecuteFilter</filter-class>
is changed to: org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter

2. Other problems occurred after the change: tomcat could not start normally and reported many errors.
Solution: Add another jar package: log4j-api-2.7.jar

At this point, tomcat starts normally, struts2 can also accurately intercept objects, and the page displays normally.

伊谢尔伦

Check if the project’s build path contains the packages you added.

PHPzhong

You did not import the package into the classpath

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template