[英]how my web application will access jsp files if i put security constraint in web.xml
[英]How to stop drect access to my jsp page even when i am using security-constraint in web.xml in struts 1.2
我正在使用struts 1.2並使用global-forwards來訪問我的jsp文件,並且即使在將/ pages / *設置為安全約束之后,也已經在我的web.xml文件中添加了安全約束,我可以控制通過URL http:/來直接訪問我的jsp。 /localhost:8080/mywebsite/pages/home.jsp,但是每當有人將鼠標指向我的菜單項時,他都可以看到http:// localhost:8080 / mywebsite / home.do這樣的網址 ,而我在iframe中卻沒有顯示任何內容可以通過點擊上面的URL來停止直接訪問home.jsp並能夠看到home.jsp,我只想在下面的index.jsp的iframe中顯示它是安全約束,我也正在使用,我不使用像<url-pattern>*.do</url-pattern>
這樣的約束<url-pattern>*.do</url-pattern>
。do <url-pattern>*.do</url-pattern>
即使在iframe中也顯示home.jsp,此操作也將停止。
<security-constraint>
<web-resource-collection>
<web-resource-name>JSP Files</web-resource-name>
<description>No direct access to JSP files</description>
<url-pattern>/pages/*</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description>No direct browser access to JSP files</description>
<role-name>NobodyHasThisRole</role-name>
</auth-constraint>
</security-constraint>
這是我的struts-config.xml中的配置
<global-forwards>
<forward name="home" path="/home.do"/>
</global-forwards>
<action-mappings>
<action path="/home" forward="/pages/home.jsp"/>
</action-mappings>
將JSP文件放在/WEB-INF
。 服務器不會在/WEB-INF
文件夾中提供任何服務。 您甚至不需要在web.xml
使用安全規則。 有關更多詳細信息,請參見“雅加達Struts-戰Seven中的七個教訓”,第4章,“ 保護WEB-INF后面的JSP ”。
完成后,您便可以通過Struts操作控制對您主頁的訪問。 這就是使用Struts的全部想法,因此您不再直接訪問JSP文件,而是始終執行*.do
操作。
如果您想保護所有請求的JSP(當請求來自iframe
時除外),那是不可能的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.