上下文路径/HelloWorldStruts2 处的应用程序无法启动 [英] Application at context path /HelloWorldStruts2 could not be started

查看:37
本文介绍了上下文路径/HelloWorldStruts2 处的应用程序无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个 Struts 2 应用程序,但出现此错误

This is the my first Struts 2 application and I got this error

"Application at context path `/HelloWorldStruts2` could not be started" 

在 Tomcat 上部署时.

when deploying on 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 应用程序:

struts.xml of my struts application:

<?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>

推荐答案

我认为问题出在 web.xml 架构版本和过滤器(正如其他人提到的).这个对我有用:

I think the problem is in the web.xml schema version and the filter (as mentioned by others). This one works for me :

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

  <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.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

</web-app>

这篇关于上下文路径/HelloWorldStruts2 处的应用程序无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆