idea中配置struts2提示找不到org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter类

“java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter”

在这里插入图片描述

一、首先,先检查是不是struts版本的问题,如果是低版本(2.2以下的),filter-class配置是这样的

<filter-class>
      org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>

高版本的filter-class的配置

<filter-class>
      org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>

二、filter-class确认没问题之后,应该就是tomcat的问题了,在本地tomcat的lib目录下放struts2相应的jar包

找到本地tomcat的安装路径,找到lib
在这里插入图片描述
先下载jar包(struts2.3.37 jar包下载链接
在这里插入图片描述
参照maven添加的依赖,在下载好的struts里找到相应的jar包,总共是11个
在这里插入图片描述
把jar包拉进tomcat的lib文件夹里,然后重启tomcat就可以了

在这里插入图片描述

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
struts 2.3.4.1 最新英文版API =========================================================== 概览 程序包 使用 树 已过时 索引 帮助 上一个 下一个 框架 无框架 所有 ----------------------------------------------------------- Struts 2.3.4.1 API 程序包 程序包 说明 ------------------------------------------------------------ com.opensymphony.xwork2 Main XWork interfaces and classes. com.opensymphony.xwork2.config Configuration core classes. com.opensymphony.xwork2.config.entities Configuration entity classes. com.opensymphony.xwork2.config.impl Configuration implementation classes. com.opensymphony.xwork2.config.providers Configuration provider classes. com.opensymphony.xwork2.conversion com.opensymphony.xwork2.conversion.annotations Type conversion annotations. com.opensymphony.xwork2.conversion.impl com.opensymphony.xwork2.conversion.metadata Type conversion meta data classes. com.opensymphony.xwork2.inject Guice (pronounced "juice"). com.opensymphony.xwork2.inject.util Guice util classes. com.opensymphony.xwork2.interceptor Interceptor classes. com.opensymphony.xwork2.interceptor.annotations Interceptor annotations. com.opensymphony.xwork2.mock XWork specific mock classes. com.opensymphony.xwork2.ognl com.opensymphony.xwork2.ognl.accessor com.opensymphony.xwork2.spring Spring ObjectFactory classes. com.opensymphony.xwork2.spring.interceptor Spring specific interceptor classes. com.opensymphony.xwork2.test com.opensymphony.xwork2.util XWork util classes. com.opensymphony.xwork2.util.classloader com.opensymphony.xwork2.util.finder com.opensymphony.xwork2.util.fs com.opensymphony.xwork2.util.location Classes and utilities used to track location information. com.opensymphony.xwork2.util.logging com.opensymphony.xwork2.util.logging.commons com.opensymphony.xwork2.util.logging.jdk com.opensymphony.xwork2.util.profiling Classes to enable profiling of action execution. com.opensymphony.xwork2.util.reflection com.opensymphony.xwork2.validator XWork validation subsystem. com.opensymphony.xwork2.validator.annotations Validator annotations. com.opensymphony.xwork2.validator.metadata Validator meta data classes. com.opensymphony.xwork2.validator.validators XWork default validator classes. org.apache.struts2 org.apache.struts2.components org.apache.struts2.components.template org.apache.struts2.config Classes for Struts configuration and property handling. org.apache.struts2.dispatcher Classes for action dispatching in Struts (the Controller part of MVC). org.apache.struts2.dispatcher.mapper org.apache.struts2.dispatcher.multipart Classes to help dispatch multipart HTTP requests. org.apache.struts2.dispatcher.ng This package contains a reimagining of the traditional Struts filter dispatchers. org.apache.struts2.dispatcher.ng.filter org.apache.struts2.dispatcher.ng.listener org.apache.struts2.dispatcher.ng.servlet org.apache.struts2.impl org.apache.struts2.interceptor org.apache.struts2.interceptor.debugging org.apache.struts2.interceptor.validation org.apache.struts2.servlet.interceptor org.apache.struts2.util org.apache.struts2.views org.apache.struts2.views.annotations org.apache.struts2.views.freemarker org.apache.struts2.views.freemarker.tags org.apache.struts2.views.jsp Struts's JSP tag library. org.apache.struts2.views.jsp.iterator org.apache.struts2.views.jsp.ui org.apache.struts2.views.util Miscellaneous helper classes for all views. org.apache.struts2.views.velocity Classes for views using Velocity. org.apache.struts2.views.velocity.components org.apache.struts2.views.xslt The new xslt view supports an extensible Java XML adapter framework that makes it easy to customize the XML rendering of objects and to incorporate structured XML text and arbitarary DOM fragments into the output. ------------------------------------------------------------ 概览 程序包 使用 树 已过时 索引 帮助
有关struts2下载组件的具体介绍我就在此略过了,看此文的同志想必大多是碰到这样让人很是不爽的问题。 下面就将该问题的最终解决办法介绍如下。 问题概要: 在struts2使用result里type="stream"的结果型时,可以实现文件的下载管理,使用时也是比较顺畅,但是当在“下载提示窗口”点击“取消按钮”时,总是报出“java.lang.IllegalStateException”异常,异常内容如下: 2011-1-8 20:34:20 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet default threw exception java.lang.IllegalStateException at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:407) at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:108) at com.opensymphony.module.sitemesh.filter.PageResponseWrapper.sendError(PageResponseWrapper.java:176) at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:108) at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:770) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:505) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:662) 网络解决办法: (虽然该办法可行,但是本人并不提倡。具体原因在之后解释。) 在网络查询解决办法大多是使用异常处理的办法,其内容如下: <package name="default" extends="struts-default"> <global-results> <result name="client-abort-exception">/ignored.jsp</result> </global-results> </package> <package name="main" extends="struts-default"> <exception-mapping result="client-abort-exception" exception="org.apache.catalina.connector.ClientAbortException"/> <action name="download" class="com.DownloadAction"> <result name="success" type="stream"> <param name="inputName">targetFile</param> <param name="contentDisposition">filename=""</param> <param name="buffersize">4096</param> </result> </action></package> 也就是说,如果抛出了ClientAbortException异常,那就跳转到“ignored.jsp”这个页面,这个页面什么内容都没有。 还有一种办法是在页面进行try..catch,之后什么都不做 异常原因分析: stream对应的org.apache.struts2.dispatcher.StreamResult,该的处理过程如下: 1。配置result标签下的各个参数 2。从服务器获取输入流,并同时与客户端建立输出流(服务器与客户端链接通过Socket进行连接) 3。当点击“保存”或“打开”时,开始传输数据。如果点击“取消”,关闭所有的流。 这里要注意的是,但是实际发现Socket并没有断开!并且流也没有关闭!这一点非常重要! 所以在JSP容器通过Response获取输出流之前,前面的流并没有关闭,所以会造成该异常的报出。 本文解决办法: 在前面所说的网络解决办法,使用的是一种躲避的方式解决该问题,也就是置之不理。 这里提供一个办法可以从根本上解决该问题,但是需要下载插件,在附件有下载,这个插件很小,才4KB而已。 《如果附件下载后文件损坏,可以到http://down.51cto.com/data/158982下载资源,不需要下载豆。》 具体做法如下: 1。将附件解压获取struts2-sunspoter-stream-1.0.jar,并复制在/WEB-INF/lib下 2。在原有的struts.xml的基础上进行相应的配置配置如下例 <package name="default" namespace="/" extends="struts-default"> <!-- 添加如下内容 --> <result-types> <result-type name="streamx" class="com.sunspoter.lib.web.struts2.dispatcher.StreamResultX"/> </result-types> <action name="download" class="com.DownloadAction"> <!-- type改写 --> <result name="success" type="streamx"> <result name="success" type="streamx"> <!-- 下载文件型定义 --> <param name="contentType">text/plain</param> <!-- 下载文件处理方法 --> <param name="contentDisposition"> attachment;filename="${downloadChineseFileName}" </param> <!-- 下载文件输出流定义 --> <param name="inputName">downloadFile</param> </result> </action> </package> 在这种方式下,只需添加一个result-type,将原有的resulttype改为“streamx”,其他一律不变,在这种情况下,点击“取消”的同时也关闭了流,不会再报出该异常。 之后的执行“取消”后的结果如下:(配置了"log4j.properties"才能看到该结果) 21:23:44,676 WARN StreamResult:45 - StreamResultX Warn : socket write error 如果出现该警告说明正确执行,该警告说明,Socket非正常断,但是流确实已经关闭,自此再也不用看到上面出现的讨厌异常结果。 转载至 http://sunspot.blog.51cto.com/372554/474983
struts.action.extension The URL extension to use to determine if the request is meant for a Struts action 用URL扩展名来确定是否这个请求是被用作Struts action,其实也就是设置 action的后缀,例如login.do的'do'字。 struts.configuration The org.apache.struts2.config.Configuration implementation class org.apache.struts2.config.Configuration接口名 struts.configuration.files A list of configuration files automatically loaded by Struts struts自动加载的一个配置文件列表 struts.configuration.xml.reload Whether to reload the XML configuration or not 是否加载xml配置(true,false) struts.continuations.package The package containing actions that use Rife continuations 含有actions的完整连续的package名称 struts.custom.i18n.resources Location of additional localization properties files to load 加载附加的国际化属性文件(不包含.properties后缀) struts.custom.properties Location of additional configuration properties files to load 加载附加的配置文件的位置 struts.devMode Whether Struts is in development mode or not 是否为struts开发模式 struts.dispatcher.parametersWorkaround Whether to use a Servlet request parameter workaround necessary for some versions of WebLogic (某些版本的weblogic专用)是否使用一个servlet请求参数工作区(PARAMETERSWORKAROUND) struts.enable.DynamicMethodInvocation Allows one to disable dynamic method invocation from the URL 允许动态方法调用 struts.freemarker.manager.classname The org.apache.struts2.views.freemarker.FreemarkerManager implementation class org.apache.struts2.views.freemarker.FreemarkerManager接口名 struts.i18n.encoding The encoding to use for localization messages 国际化信息内码 struts.i18n.reload Whether the localization messages should automatically be reloaded 是否国际化信息自动加载 struts.locale The default locale for the Struts application 默认的国际化地区信息 struts.mapper.class The org.apache.struts2.dispatcher.mapper.ActionMapper implementation class org.apache.struts2.dispatcher.mapper.ActionMapper接口 struts.multipart.maxSize The maximize size of a multipart request (file upload) multipart请求信息的最大尺寸(文件上传用) struts.multipart.parser The org.apache.struts2.dispatcher.multipart.MultiPartRequest parser implementation for a multipart request (file upload) 专为multipart请求信息使用的org.apache.struts2.dispatcher.multipart.MultiPartRequest解析器接口(文件上传用) struts.multipart.saveDir The directory to use for storing uploaded files 设置存储上传文件的目录夹 struts.objectFactory The com.opensymphony.xwork2.ObjectFactory implementation class com.opensymphony.xwork2.ObjectFactory接口(springstruts.objectFactory.spring.autoWire Whether Spring should autoWire or not 是否自动绑定Spring struts.objectFactory.spring.useClassCache Whether Spring should use its class cache or not 是否spring应该使用自身的cache struts.objectTypeDeterminer The com.opensymphony.xwork2.util.ObjectTypeDeterminer implementation class com.opensymphony.xwork2.util.ObjectTypeDeterminer接口 struts.serve.static.browserCache If static content served by the Struts filter should set browser caching header properties or not 是否struts过滤器提供的静态内容应该被浏览器缓存在头部属性 struts.serve.static Whether the Struts filter should serve static content or not 是否struts过滤器应该提供静态内容 struts.tag.altSyntax Whether to use the alterative syntax for the tags or not 是否可以用替代的语法替代tags struts.ui.templateDir The directory containing UI templates UI templates的目录夹 struts.ui.theme The default UI template theme 默认的UI template主题 struts.url.http.port The HTTP port used by Struts URLs 设置http端口 struts.url.https.port The HTTPS port used by Struts URLs 设置https端口 struts.url.includeParams The default includeParams method to generate Struts URLs 在url产生 默认的includeParams struts.velocity.configfile The Velocity configuration file path velocity配置文件路径 struts.velocity.contexts List of Velocity context names velocity的context列表 struts.velocity.manager.classname org.apache.struts2.views.velocity.VelocityManager implementation class org.apache.struts2.views.velocity.VelocityManager接口名 struts.velocity.toolboxlocation The location of the Velocity toolbox velocity工具盒的位置 struts.xslt.nocache Whether or not XSLT templates should not be cached 是否XSLT模版应该被缓存

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值