建立在你的網頁內容的空文件名的歡迎folder.Add follwinf進入到你的web.xml
<filter>
<filter-name>action2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>action2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
取代在web.xml中的歡迎列表文件
<welcome-file-list>
<welcome-file>welcome</welcome-file>
</welcome-file-list>
和最後在你的strus.xml中做一些類似的事情
<action name="welcome" class="welcome.action">
<result>/index.jsp</result>
</action>
我們試圖做的是,當我們打到example.com
而不是顯示歡迎的jsp文件,我們正在執行操作並使用其結果。在這種情況下,您的網址將保持不變,如www.mysite.com
與重定向不同,因爲在所有情況下URL都是www.mysite。 COM /歡迎,但我希望它是簡單的,如www.mysite.com –
@ user577691然後使用第二種機制。您也可以嘗試使用JSTL include。 –
可能是我理解錯誤的方式,但如果我會去第二個選項的調度員仍然在我的歡迎文件列表中我必須定義動作的URL,所以我相信動作的URL會像www.mysite.com/歡迎「歡迎」將成爲行動的名稱。 –