1

JSF マネージド Bean 内に、この過去の質問から取得した次のコードがあります。

String uri = "/myAction";
FacesContext.getCurrentInstance().getExternalContext().dispatch(uri);

myActionmy で定義されている Struts アクションの名前ですstruts.xml

ただし、JSF Bean にアクセスすると、転送されません/myAction。代わりに、404 http エラーが発生します: The requested resource (/MyApp/myAction) is not available.

どうしてうまくいかないの??

/myActionブラウザから直接アクセスしようとすると、http://localhost:8080/MyApp/myActionすべて正常に動作します。

4

2 に答える 2

0

Struts 2 フィルターを設定しweb.xmlて、転送 (および直接要求 (またはリダイレクト)) を受け入れるようにします。

web.xmlで、次を変更します。

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

に:

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

    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <!-- uncomment if you plan to include struts action output -->
    <!--
    <dispatcher>INCLUDE</dispatcher>
    -->
</filter-mapping>

クレジット:

http://www.coderanch.com/t/59584/Struts/request-dispatcher-struts-action

http://docs.oracle.com/cd/B32110_01/web.1013/b28959/filters.htm#BCFIEDGB

于 2013-04-18T13:59:52.720 に答える