0
我在WEB-INF文件夾外有幾個文件夾,這些文件夾包含jsp文件。阻止訪問WEB_INF外的內容(jsp文件)
Sample Directory structure:
-WEB-INF
-DirA
-a.jsp
-b.jsp
-DirB
-c.jsp
-d.jsp
如何阻止用戶訪問所述靜態文件(JSP)的所述WEB-INF文件夾以外的websphare 8服務器?
我在WEB-INF文件夾外有幾個文件夾,這些文件夾包含jsp文件。阻止訪問WEB_INF外的內容(jsp文件)
Sample Directory structure:
-WEB-INF
-DirA
-a.jsp
-b.jsp
-DirB
-c.jsp
-d.jsp
如何阻止用戶訪問所述靜態文件(JSP)的所述WEB-INF文件夾以外的websphare 8服務器?
您將需要在web.xml中指定安全約束。一個好的教程Web應用程序的安全性可以在這裏找到: http://docs.oracle.com/javaee/5/tutorial/doc/bncbx.html
基本上,你需要這樣的事情在你的web.xml:
<security-constraint>
<display-name>SecurityConstraintForDirA</display-name>
<web-resource-collection>
<web-resource-name>DirAResources</web-resource-name>
<url-pattern>/DirA/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>dirAUsers</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
希望這有助於安迪
感謝。我之前檢查過這個。因爲我在WEB-INF目錄外有多個文件夾。如果我想用這種方式,我需要在web.xml中添加每個文件夾。有沒有其他的方式來阻止它在websphare設置? – jAnA
此鏈接可能也是有用的: https://www.ibm.com/developerworks/websphere/techjournal/1303_lansche/1303_lansche.html 請注意,您可以在安全約束中指定多個url模式 - 這樣您就可以擁有一個所有目錄(即/ *)或某個子集(即/ DirA,/ DirB,/ DirC)的安全約束。 我不知道任何特定於WebSphere的方法來保護多個目錄。 –