0

しばらくウェブを検索しましたが、私の問題に対する答えが見つかりませんでした。どんな洞察も大歓迎です。

https://github.com/apache/struts-examples/tree/master/helloworldの指示に従い、http://myhost.net:8080/hello_world/index.actionでサーブレットにアクセスできます 。

ここで、 hello_world の下のサーブレットをhttp://myhost.net:8080から直接アクセスできるようにしたいと考えています。次のように 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="false" />
<package name="basicstruts2" extends="struts-default">    
    <action name="index">
        <result>/index.jsp</result>
    </action>
    <action name="hello" class="helloworld.action.HelloWorldAction" method="execute">
        <result name="success">/HelloWorld.jsp</result>
    </action>
</package>
</struts>

web.xml は次のとおりです。

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

  <display-name>Hello World Struts 2</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</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>

これらの変更により、http://myhost.net:8080/index.jsp " から index.jsp にアクセスできます。ただし、 http://myhost.net:8080 "を使用して直接アクセスすることはまだできません。以下は私が得るエラーです:

HTTP ERROR 404
Problem accessing /. Reason:
There is no Action mapped for namespace [/] and action name [] associated with context path [].

コンテナーとして Jetty 8.1.15 を使用しています。

4

1 に答える 1

0

http://myhost.net:8080この URL へのアクション マッピングがないため、アクセスできません 。構成を変更する

<action name="">
    <result>/index.jsp</result>
</action>
于 2014-08-09T09:06:41.377 に答える