Java SpringSecurity绕过css图像

Java SpringSecurity绕过css图像,java,css,spring,spring-mvc,Java,Css,Spring,Spring Mvc,我使用的是SpringHTTP安全性,在绕过css、图像和其他资源时遇到了问题 我的安全xml文件如下所示 <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://

我使用的是SpringHTTP安全性,在绕过css、图像和其他资源时遇到了问题

我的安全xml文件如下所示

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
  xmlns:beans="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/security
           http://www.springframework.org/schema/security/spring-security.xsd">

    <http pattern="resources" security="none" />
    <http auto-config="true">
        <form-login login-page="/login" default-target-url="/campaign/list" authentication-failure-url="/loginError"/>
        <logout logout-success-url="/login" />              
    </http>

    <!-- <http auto-config="true">
        <intercept-url pattern="/main*" access="ROLE_ADMIN,ROLE_REGULAR_USER" />
        <form-login login-page="/login" default-target-url="/main"
            authentication-failure-url="/loginError"/>
    </http> -->

    <!-- Select users and user_roles from database -->
    <authentication-manager>
      <authentication-provider>
        <jdbc-user-service data-source-ref="dataSource"
          users-by-username-query=
            "select username,password, enabled from users where username=?"
          authorities-by-username-query=
            "select username, role from user_roles where username =?  " />
      </authentication-provider>
    </authentication-manager>    

</beans:beans>

我试过了

<http security="none" pattern="/resources/css/style.css"/>
<intercept-url pattern="/resources*" access="IS_AUTHENTICATED_ANONYMOUSLY" /> 
<security:intercept-url pattern="/resources/**" access="permitAll" />

但这些都不起作用 请告诉我可以使用哪些代码绕过资源。

您可以尝试使用:

<http pattern="resources" security="none" />


但是您必须确保此模式下的所有内容都可以是公共的。

您需要为静态资源定义
,如下所示:

<intercept-url pattern="/resources/**" filters="none" />

除了先前建议的

<http pattern="/resources/**" security="none"/>

有关更多信息,请参阅。

我已经添加了这一点,但仍然没有成功。我已经把你的更改放在问题代码里了,还有这个。您使用的是哪个spring安全版本?我使用的是spring 4.0.6版本。该版本可能是Spring framework的一个版本,但不是您的Spring security版本。最新版本是3.2.6,您可以在
<resources mapping="/resources/**" location="/resources/" />