**无法在web.xml安全约束中使用 [英] ** not working in web.xml security-contraints
问题描述
我想不受限制地访问/gadgets/{任何目录}/css/*. 我想这样提
I want to have unrestricted access for /gadgets/{any directory}/css/*. I tried to mention like this
<security-constraint>
<web-resource-collection>
<web-resource-name>UnProtected Area</web-resource-name>
<url-pattern>/gadgets/**/css/*</url-pattern>
</web-resource-collection>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/gadgets/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>LOGIN</role-name>
</auth-constraint>
</security-constraint>
但是它不起作用.
推荐答案
我遇到了同样的问题.我的* .css和* .js文件位于WebRoot/resources/css
和WebRoot/resources/script
中.要访问这些文件,我在"*-servlet.xml"
中添加了行<mvc:resources mapping="/resources/**" location="/resources/" />
.
现在,我通过将以下代码作为最后一个安全约束添加到我的web.xml
中,从而允许访问所有用户角色:
<security-constraint>
<web-resource-collection>
<web-resource-name>CSS and JS Files</web-resource-name>
<url-pattern>/resources/*</url-pattern>
</web-resource-collection>
</security-constraint>
我希望这会有所帮助.
i got the same Problem. My *.css and *.js Files are located in WebRoot/resources/css
and in WebRoot/resources/script
. To access those files I added the line <mvc:resources mapping="/resources/**" location="/resources/" />
to my "*-servlet.xml"
.
Now I allowed access for all user-roles by adding following code to my web.xml
as the last security-constraint:
<security-constraint>
<web-resource-collection>
<web-resource-name>CSS and JS Files</web-resource-name>
<url-pattern>/resources/*</url-pattern>
</web-resource-collection>
</security-constraint>
I hope this helps.
这篇关于**无法在web.xml安全约束中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!