2009-12-15 212 views
0

Servlet的web.xml中驗證我有一個web.xml看起來像:的歡迎

<web-app> 

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

<security-constraint> 
    <web-resource-collection> 
    <web-resource-name>Default</web-resource-name> 
    <url-pattern>/</url-pattern> 
    </web-resource-collection> 
    <auth-constraint/> 
</security-constraint> 

<security-constraint> 
    <web-resource-collection> 
    <web-resource-name>Index page</web-resource-name> 
    <url-pattern>/index.jsp</url-pattern> 
    <url-pattern>/</url-pattern> 
    <http-method>GET</http-method> 
    <http-method>HEAD</http-method> 
    </web-resource-collection> 
</security-constraint> 
... 

我們要拒絕默認情況下對資源的訪問,並指定我們希望允許訪問的資源。

如果用戶去http://localhost:8080/他們得到的卻拒絕訪問,如果去http://localhost:8080/index.jsp它允許他們兩個網址應顯示在同一個頁面,都應該被允許。我在這裏做錯了什麼?

回答

4

我覺得做事情會指定/*趕上默認值,不喜歡/somethingElse.jsp特定的模式,以趕上那是 index.jsp的任何其他頁面。希望你的頂級「目錄」不是很混亂。

+2

你不需要考慮。你是對的:) – BalusC 2009-12-16 19:00:00

+2

我要採取這種說法,用大寫字母打印出來,將它掛在桌子上並掛起來:) – 2009-12-16 19:14:15