標籤:style c class blog code java
本來是弄攔截器的問題,結果弄首頁的時候,還是發現了問題。
公司網站的項目裡面,是用index.action作為首頁的,訪問WEB-INF裡面的html檔案。可是我設定的卻不成功,追根到底,一個原因,struts2比較特殊,struts.xml裡面必須多配置一個request和response。
<?xml version="1.0" encoding="UTF-8"?><web-app id="WebApp_9" version="3.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd"> <display-name>Struts Blank</display-name> <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> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> <welcome-file-list> <welcome-file>index.action</welcome-file> </welcome-file-list></web-app>
這樣就可以便於使用index.action作為首頁。
另外這樣配置後,也可以用jsp裡面加forward來跳轉到index.action作為首頁。也可以用html裡面加一個<meta>標籤重新整理跳轉到首頁action裡面。
不經過request和response,只能用html加<meta>標籤的方式。
另:eclipse編輯web.xml的時候,總是卡死,是因為xml頭版本的問題,裡面的版本數字要一致。
<?xml version="1.0" encoding="UTF-8"?><web-app id="WebApp_9" version="3.0" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd">
如上,都是3.0的。