今天嘗試使用struts2+ urlrewrite+sitemesh部署項目,結果發現welcome-file-list中定義的歡迎頁不起作用:
<welcome-file-list> <welcome-file>/index.jsp</welcome-file> </welcome-file-list>
啟動服務器后,直接輸入http://localhost:8080/project 終是報404錯誤,初步猜測是由於沒有找到index.jsp這個文件造成的,於是在web-root下新建一個空白的index.jsp;重新啟動之后成功顯示,但是由於welcome-file中不能直接寫action,所以對index.jsp進行改造:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <jsp:forward page="/index.html" />
這樣就達到了只輸入項目名就可訪問的目的: 直接輸入 http://localhost:8080/ project