2012-05-03 92 views
1

運行下面我有以下線在web.xml歡迎辭在Struts 2的谷歌應用程序引擎

<welcome-file-list> 
    <welcome-file>index.jsp</welcome-file> 
</welcome-file-list> 

但是,當我訪問http://localhost:8888我收到以下錯誤:

There is no Action mapped for namespace [/] and action name 
[] associated with context path []. 

」不是個它被重定向到index.jsp?如何使歡迎文件的工作?

回答

0

我認爲你已經正確配置了歡迎文件。錯誤消息看起來像一個struts錯誤消息。看起來你有一個struts配置問題。在你的struts.xml文件中檢查你的動作類配置。

+0

它說動作名稱[],這意味着一個空的動作叫什麼名字? –

0

請編輯您的struts.xml,並將此操作作爲最後一個操作輸入(僅限所有操作爲默認操作後)。

<action name="*"> 
    <result type="redirectAction"> 
    <param name="actionName">Home.action</param> 
    </result> 
</action> 

現在,這必須是最後一個操作,它將像您的應用程序的默認操作一樣工作。如果應用程序未找到任何已配置的操作,它將被重定向到此操作。

0

在「/」軟件包命名空間中將下面的空白操作添加到你的struts.xml文件中,當你只嘗試訪問你的url時(如appid.app.com)它會顯示index.html,它不會顯示錯誤。通常它會添加一個空白動作,應用程序引擎會將空白動作重定向到歡迎文件。

<action name="" class="com.candi.actions.Dashboard" method="noAction"> 
     <result name="success">index.jsp</result> 
    </action> 

讓我們進一步解釋。只需通過提供空白「」作爲您的動作名稱並將您的結果重定向到index.php來解決您的問題,即可添加空白動作。

1

運行服務器後,它正在搜索一個操作。 你應該在struts.xml中某個動作映射到JSP文件

而且添加在下面的web.xml

<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>