av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術文章
文章詳情頁

SpringBoot+SpringSecurity 不攔截靜態資源的實現

瀏覽:3日期:2023-04-22 11:58:52

一、問題描述

在 SpringBoot 中加入 SpringSecurity 中之后,靜態資源總是被過濾,導致界面很難看:

SpringBoot+SpringSecurity 不攔截靜態資源的實現

目錄結構:

SpringBoot+SpringSecurity 不攔截靜態資源的實現

二、問題解決

正常不攔截資源,我查閱資料,基本都是重新 config 方法即可:

package org.yolo.securitylogin.config;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;import org.springframework.security.config.annotation.web.builders.HttpSecurity;import org.springframework.security.config.annotation.web.builders.WebSecurity;import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;import org.springframework.security.crypto.password.NoOpPasswordEncoder;import org.springframework.security.crypto.password.PasswordEncoder;/** * @Auther: Yolo * @Date: 2020/9/12 13:05 * @Description: */@Configurationpublic class SecurityConfig extends WebSecurityConfigurerAdapter { @Bean PasswordEncoder passwordEncoder() { return NoOpPasswordEncoder.getInstance(); } @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { //在內存中進行配置 auth.inMemoryAuthentication().withUser('yolo').password('123').roles('admin'); } @Override public void configure(WebSecurity web) throws Exception { //web.ignoring().antMatchers('/static/js/**', '/static/css/**', '/static/images/**'); web.ignoring().antMatchers('/js/**', '/css/**','/images/**'); } @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().anyRequest().authenticated().and().formLogin().loginPage('/login.html').permitAll()//跟登錄相關的頁面統統放行.and().csrf().disable() ; }}

常規方法是:

@Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers('/js/**', '/css/**','/images/**'); }

SpringBoot+SpringSecurity 不攔截靜態資源的實現

這里一定要謹記,這樣配置了 configure,之后,一定要清除 target,不然是不會生效的

SpringBoot+SpringSecurity 不攔截靜態資源的實現

到此這篇關于SpringBoot+SpringSecurity 不攔截靜態資源的實現的文章就介紹到這了,更多相關SpringBoot+SpringSecurity 不攔截靜態資源內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: 91亚洲精选 | 国产成人精品免费 | 天天干天天草 | 日韩在线视频免费观看 | 黄色网页在线 | 亚洲免费网站 | 中文字幕在线观看网址 | av一二三区 | 国产日韩精品一区二区 | 欧美精品二区三区四区免费看视频 | 欧美性猛交乱大交 | 97在线免费观看视频 | 天天干天天操 | 亚洲黄色在线视频 | 成年人毛片 | 日本精品视频 | 亚洲欧美日韩在线 | av网址在线免费观看 | 深夜福利网 | 国产精品伦子伦免费视频 | 一级做a爱片性色毛片 | 欧美日韩在线免费观看 | 成人在线a | 国产欧美成人 | 污视频网站在线观看 | 国产视频一二三区 | 午夜www| av网站在线免费观看 | 免费毛片观看 | 天天干天天干天天干 | 亚洲伊人av | 国产成人午夜高潮毛片 | 高清一区二区 | 男女啪啪免费 | 久久久久久网 | 日韩av专区| 97精品国产97久久久久久免费 | 亚洲国产三级 | 在线视频一区二区三区 | 亚洲激情在线播放 | www国产 |