springSecurity安全框架需要引入配置文件spring-security.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="/login.html" security="none"/>
    <http pattern="/login_error.html" security="none"/>
<!--    頁面攔截規則  use-expressions禁用spel表達式  access訪問這個路徑的權限 寫法必須以ROLE開頭 后邊跟大寫字母-->
<http use-expressions="false">
    <intercept-url pattern="/**" access="ROLE_USER"/>
<!--login-page指定登陸頁面   default-target-url指定登陸成功后默認的頁面   authentication-failure-url登陸失敗后默認的頁面-->
    <form-login login-page="/login.html" default-target-url="/index.html" authentication-failure-url="/login_error.html" />
<!--跨域訪問禁用-->
    <csrf disabled="true"/>
</http>
    <!--認證管理器-->
   <authentication-manager>
       <authentication-provider>
           <user-service>
               <user name="admin" password="123456" authorities="ROLE_USER"/>
           </user-service>
       </authentication-provider>
   </authentication-manager>
</beans:beans>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM