2016-03-31 18 views
1

私のウェルカムファイルはindex.jspです。HomeAction.doにリダイレクトします。 だから私は書いた:response.sendRedirectを使用してstruts1アクションにリダイレクトできません

<% 
    response.sendRedirect("HomeAction.do"); 
%> 

しかし、それは404エラーを与える。正確なURLを取得するにはどうすればよいですか?私のHomeActionはBaseActionを拡張し、BaseActionはActionを拡張します。

enter image description here

+0

関連するアクション部分を 'struts-config.xml'からポストしてください。 –

答えて

0

のStruts 1.xのは、2013年4月5日のようEnd Of Life状態に達している、だから、1.xのバージョンを使用することをお勧めしません。

index.jspファイルに、スクリプトレットの代わりに<jsp:forward>タグを使用してください。

<jsp:forward page="HomeAction.do"/> 

そして、あなたのstruts-config.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE struts-config PUBLIC 
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" 
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd"> 

<struts-config> 
    <action-mappings> 
     <action 
      path="/HomeAction" 
      type="org.apache.struts.actions.ForwardAction" 
      parameter="/welcomeStruts1.jsp"/> 
    </action-mappings> 

    <servlet-mapping> 
     <servlet-name>action</servlet-name> 
     <url-pattern>*.do</url-pattern> 
    </servlet-mapping> 

</struts-config> 

で詳細Configure a welcome page in Strutsを参照してください。お役に立てれば。

+0

私は昨日の上級幹部から同様の解決策を得ました!とにかく、ありがとう! – JG1991

+0

歓迎です.. ..!それを[受け入れられた回答](http://stackoverflow.com/help/accepted-answer)としてマークしてください。他の人がこの回答のメリットを得るでしょう。 –

関連する問題