gpt4 book ai didi

java - Struts2 导致错误

转载 作者:行者123 更新时间:2023-11-30 06:21:22 27 4
gpt4 key购买 nike

我有一个使用 Eclipse、Struts2 并在 Tomcat 7 服务器上运行的 Web 应用程序。

我已经离开了 http://javabrains.koushik.org教程。

我已经准备好所有基本的 Struts 部分,但出于某种原因,当我将这段代码引入 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>

它把书扔给我。

SEVERE: Dispatcher initialization failed
Unable to load configuration. - bean -
Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean -
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name struts has already been loaded by bean -
SEVERE: Exception starting filter struts2
Unable to load configuration. - bean -
Caused by: Unable to load configuration. - bean -
Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean -
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name struts has already been loaded by bean - jar:file:/C:/Program%20Files%20(x86)/Apache%20Software%20Foundation/Tomcat%207.0/lib/struts2-core-2.3.16.jar!/struts-default.xml:40:72
- bean -

我知道这不是完整的文本转储,但我不知道它的其余部分会有多大用处。我需要了解它为什么这样做,这样我才能让它工作。

最佳答案

您不应将特定于应用程序的 jar 复制到服务器 lib 文件夹。而是使用 WEB-INF/lib。从服务器 lib 中删除 struts2-core-2.3.16.jar。如果您在 WEB-INF/lib 中有另一个 struts2-core-x.x.x.jar,它会阻止 Tomcat 部署您的应用程序,因为来自 Tomcat lib 的库在部署任何应用程序之前加载文件夹。它停止部署。 Tomcat lib 文件夹应仅包含运行 Web 容器所需的 Tomcat 安装的 jar,除非您知道自己在做什么,否则无需将其他 jar 复制到那里。

关于java - Struts2 <filter> 和 <filter-mapping> 导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20614644/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com