【发布时间】:2025-12-05 18:20:06
【问题描述】:
这是我的第一个 Struts 2 应用程序,我收到了这个错误
"Application at context path `/HelloWorldStruts2` could not be started"
在 Tomcat 上部署时。
web.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_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>Struts 2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<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>
</web-app>
struts.xml 我的 struts 应用程序:
<?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.devMode" value="true" />
<package name="helloworld" extends="struts-default">
<action name="hello"
class="com.tutorialspoint.struts2.HelloWorldAction"
method="execute">
<result name="success">/HelloWorld.jsp</result>
</action>
</package>
</struts>
【问题讨论】:
-
服务器日志中有什么?您正在部署哪些库?
-
您可能使用的是旧过滤器:*.com/a/17103563/1654265
-
哦,什么版本的 S2?正如 Andrea 所提到的,这是一个已弃用的过滤器,尽管它应该仍然可以工作。
-
@AndreaLigios: 更换过滤器后仍然报同样的错误
-
@DaveNewton: struts-2.3.15
标签: java tomcat struts2 struts applicationcontext