1

私が文書を正しく誤解したので、問題はばかげているようです。基本的には、hello.jspファイルをWEB-INF / contentに追加してlocalhost:8080 / test / helloを実行するだけで、この指示に従ってhello-worldアクションレスの例を実行したいのですが、Strutsは例外java.langを表示し続けます。 NoSuchMethodException:com.opensymphony.xwork2.ActionSupport.index()

ですから、実行する前に構成を行う必要があるのではないかと思います。hello-worldの例の構成については何も見つかりませんでした。

誰かが私に正しい方法を提案できますか?ありがとう

更新:ここにプロジェクトツリーがあり、アクションもファンシーもありません。

├── pom.xml
└── src
    └── main
        ├── resources
        │   └── struts.xml
        └── webapp
            ├── WEB-INF
            │   ├── content
            │   │   └── hello.jsp
            │   └── web.xml
            └── index.jsp

pom.xmlの依存関係

<dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>2.3.8</version>
    </dependency>

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-rest-plugin</artifactId>
        <version>2.3.8</version>
    </dependency>

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-convention-plugin</artifactId>
        <version>2.3.8</version>
    </dependency>

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-config-browser-plugin</artifactId>
        <version>2.3.8</version>
    </dependency>

    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty</artifactId>
        <version>6.1.26</version>
    </dependency>
4

1 に答える 1

10

Struts2コンベンションプラグインとStruts2RESTプラグインを混在させたため、Struts 2はindex()(RESTのデフォルトメソッド)と呼ばれるメソッドを探しています。

RESTプラグインを削除します---struts2-rest-pluginそしてすべてが期待どおりに機能するはずです。

コンベンションとRESTを組み合わせたい場合は、ドキュメントを参照してください。struts.rest.namespaceアプリケーションのREST部分を通常のWebアプリケーション部分と区別するために使用できます。

編集

通常のWebアプリとRESTエンドポイントの両方を混在させたい場合は、URLごとに異なるマッパーを使用できるPrefixBasedActionMapperの使用を検討できます。さらに、PrefixBasedActionProxyFactory適切なファクトリを使用して、URLに一致するアクションを構築するために使用する必要があります。

于 2013-02-12T07:50:16.750 に答える