午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

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

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

瀏覽:4日期: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
相關文章:
主站蜘蛛池模板: 久久久精品福利 | 午夜影院在线观看视频 | 色啪影院 | 日本三级精品 | 国产精品永久久久久久久久久 | 中国一级黄色录像 | 中文字幕狠狠干 | 亚洲日本在线播放 | a国产视频 | 欧美激情影院 | 巨大黑人极品videos精品 | 激情二区 | 国模大胆一区二区三区 | 丁香六月激情 | 久久精品视频1 | 久久久成人免费视频 | 亚洲综合色视频 | 色天堂视频 | 国产精品6 | 亚洲激情一区 | 天天舔天天插 | 婷婷色吧 | 黄色九九 | 欧美午夜理伦三级在线观看 | 日韩高清不卡一区 | 黄色在线小视频 | 欧美成人另类 | 伊人天堂在线 | 三级视频在线观看 | 超碰加勒比 | 亚洲欧美另类自拍 | 国产午夜精品一区二区三区视频 | 伊人超碰| 亚洲综合av网 | 亚洲欧美激情在线 | av高清在线 | 久久视频在线观看免费 | 免费久久视频 | 成人在线播放网站 | 永久免费看片在线观看 | 欧美一级在线免费观看 |