[英]Struts dispatcher cannot be found
ERROR comes like : 错误来自:
The Struts dispatcher cannot be found. 找不到Struts调度程序。 This is usually caused by using Struts tags without the associated filter.
这通常是由于使用没有关联过滤器的Struts标记引起的。 Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag.
Struts标记仅在请求通过其servlet过滤器时可用,该过滤器初始化此标记所需的Struts调度程序。
MY struts.xml 我的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">
<display-name>Struts2 Login</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
my web.xml : 我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.action.excludePattern" value="/ServletToExcludeFromStruts*" />
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<package name="helloworld" extends="struts-default">
<action name="hello" class="com.struts.action.HelloWorldAction"
method="execute">
<result name="success">/HelloWorld.jsp</result>
</action>
</package>
</struts>
and required jar file...[correct me if i am wrong] 和所需的jar文件... [如果我错了,请纠正我]
commons-logging-1.0.4.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
struts2-core-2.0.11.jar
xwork-2.0.4.jar
commons-collections-3.0.jar
commons-fileupload-1.2.1.jar
commons-lang-2.4.jar
commons-io-1.3.2.jar
javassist-3.0.jar
Your web.xml and struts.xml are fine. 你的web.xml和struts.xml没问题。
The JARs versions are a little different from the required dependencies for Struts 2.0 : JAR版本与Struts 2.0所需的依赖项略有不同:
xwork
should be 2.0. xwork
应该是2.0。 7 , commons-io
should be 1. 0 , and so on. 如图7所示 ,
commons-io
应为1。0,依此类推。
Btw, since it seems you are starting today with a new Struts2 project, I STRONGLY suggest you to start with the latest Struts2 libraries for at least the following reasons: 顺便说一句,既然你今天开始使用新的Struts2项目,我强烈建议你从最新的Struts2库开始,至少有以下原因:
2.3.15.3
are affected by a serious security bug ; 2.3.15.3
之前的Struts2版本受到严重安全漏洞的影响 ; 2.1.3
, you must use the new filter, that is the StrutsPrepareAndExecuteFilter , as written in the FilterDispatcher documentation ) 2.1.3
,你必须使用新的过滤器,即StrutsPrepareAndExecuteFilter) ,如FilterDispatcher文档中所写) Then start a new project with the latest libraries (currently 2.3.16.1
), preferibly with Maven, or either by hand paying attention to the required dependencies and their versions . 然后使用最新的库(目前为
2.3.16.1
)开始一个新项目,最好是使用Maven,或者手工注意所需的依赖项及其版本 。
我想你已经交换了两个文件(struts.xml和web.xml)的内容,这就是你收到这个错误的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.