java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuterFilter

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13968559/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 14:35:58  来源:igfitidea点击:

java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuterFilter

javastruts2

提问by user1581439

I copied all struts2 jars to the WEB-INF/libfolder and the struts.xml file is as shown below:

我把所有的struts2 jars复制到WEB-INF/lib文件夹下,struts.xml文件如下图:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">*

I'm still getting this exception while running the application.
How can I solve this?

运行应用程序时,我仍然遇到此异常。
我该如何解决这个问题?

回答by sujith s

For new release of Struts2 class path changed as like below (Struts 2.5)

对于新版本的 Struts2 类路径更改如下(Struts 2.5)

org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter

Package names have changed Some classes were moved to different packages, see the list below for more details:

包名称已更改 某些类已移至不同的包,有关详细信息,请参阅下面的列表:



New:

新的:



org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
org.apache.struts2.dispatcher.filter.StrutsExecuteFilter
org.apache.struts2.dispatcher.filter.StrutsPrepareFilter
org.apache.struts2.dispatcher.listener.StrutsListener
org.apache.struts2.result.ServletRedirectResult
com.opensymphony.xwork2.interceptor.ValidationAware 


Old:

老的:



org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
org.apache.struts2.dispatcher.ng.listener.StrutsListener
org.apache.struts2.dispatcher.ServletRedirectResult
com.opensymphony.xwork2.ValidationAware 

For More Detail Click Here

更多详情请点击这里

回答by Harshvardhan Singh

Regarding to the error mentioned SEVERE: Exception starting filter struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

关于提到的错误严重:异常开始过滤器 struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

PROBLEM: There seems to be a problem with the following combination Eclipse - WTPPlugin - Struts2 - Maven3

问题:以下组合 Eclipse - WTPPlugin - Struts2 - Maven3 似乎有问题

FINDINGS: We assume that when we run a project as "Run on server" we assume that eclipse runs maven, created WAR file and deploys on the server. But its not working perfectly for me. I do see the WAR file in the target folder where maven creates WAR, and the WAR is perfect. But eclipse seems to run something else.

发现:我们假设当我们以“在服务器上运行”的方式运行项目时,我们假设 eclipse 运行 maven,创建 WAR 文件并部署在服务器上。但它对我来说并不完美。我确实在maven创建WAR的目标文件夹中看到了WAR文件,WAR是完美的。但是 eclipse 似乎运行其他东西。

SOLUTION: Put all the required JAR files into eclipse project's WEB-INF/lib. If you are using version control, make sure to ignore the lib folder. How to find all the required JARs when you are using maven? Go to target folder and the WAR file. Burst it open and go to WEB-INF/lib. Copy all these JARS to eclipse project's WEB-INF/lib.

解决方案:将所有需要的 JAR 文件放入 eclipse 项目的 WEB-INF/lib。如果您使用版本控制,请确保忽略 lib 文件夹。使用 maven 时如何找到所有需要的 JAR?转到目标文件夹和 WAR 文件。将其打开并转到 WEB-INF/lib。将所有这些 JARS 复制到 eclipse 项目的 WEB-INF/lib。

Thanks, Harsh

谢谢,苛刻

回答by Ahmad AlMughrabi

It happened with me, and I solve it by recreating the artifacts from Intellij settings. If you use Intellij, you need to recreate the Artifacts for your web project again.

它发生在我身上,我通过从 Intellij 设置重新创建工件来解决它。如果您使用 Intellij,则需要再次为您的 Web 项目重新创建工件。

  • Go to File --> Project structure
  • Select Artifacts from the left tab.
  • Remove the current artifacts by select the artifacts and click on (-) button at the top of your Artifacts.
  • Add new artifacts, first war exploded then war archive.
  • Enjoy.
  • 转到文件 --> 项目结构
  • 从左侧选项卡中选择工件。
  • 通过选择工件并单击工件顶部的 (-) 按钮来移除当前工件。
  • 添加新的神器,先是War爆发,然后是War档案。
  • 享受。

enter image description here

在此处输入图片说明

回答by Chetan Pulate

Include this mapping in your web.xmlfile

在您的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>