2

Struts2 を使用してこの Hello World アプリケーションを作成していたときに、

HTTP Status 404 - /HelloStruts2/

これが私のweb.xml

<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" version="3.0">
  <display-name>HelloStruts2</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.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>

これが私のstruts.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.devMode" value="true" />

    <package name="basicstruts2" extends="struts-default">

        <action name="index">
            <result>WEB-INF/index.jsp</result>
        </action>

        <action name="hello" 
            class="actions.HelloWorldAction" method="execute">
            <result name="success">/HelloWorld.jsp</result>
        </action>

    </package>

</struts>

これが私のアプリケーションのjarのリストです

commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-logging-api-1.1.jar
freemarker-2.3.19.jar
javassist-3.15.0-GA.jar
jstl-1.2.jar
ognl-3.0.5.jar
struts2-core-2.3.7.jar
xwork-core-2.3.7.jar
4

4 に答える 4

2

私はそれを修正しました.5月のディレクトリへのcommons-langjarが必要なだけであることがわかりました。lib

于 2012-12-05T10:31:36.023 に答える
1

web.xmlで次のコードセグメントを試してください(strutsフィルターユーザーのパターン* .action)

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>
于 2012-12-05T10:25:09.780 に答える
0

これは瓶の問題です。次のjarで確認してください。私は同じ問題を抱えていて、次のjarで解決しました。

commons-fileupload-1.2.1
commons-io-1.3.2
commons-logging-1.0.4
commons-logging-api-1.1
freemarker-2.3.16
javassist-3.14.0-GA
log4j-1.2.16
ognl-3.0
struts2-core-2.2.1.1
xwork-core-2.2.1.1
于 2012-12-05T10:22:01.990 に答える
0

私は同じ問題を抱えていて、上記の適切な瓶を置いても、何時間もそれを解決するのに苦労しました.

問題を引き起こしているapache tomcatのcommon->libフォルダーの下にjarファイルが多すぎるため、この問題に直面しました。

そう

1) jar とその依存関係をきちんと保持します。2) 依存関係について、web-inf の lib フォルダーの下にある jar を確認します。3) 同じクラスを含むがバージョンが異なる jar をチェックします。

Tomcatをアンインストールして再インストールしたときに解決策が見つかりました。

于 2013-11-18T13:55:54.343 に答える