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

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

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

瀏覽:6日期: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
相關文章:
主站蜘蛛池模板: 99re视频在线观看 | 中文字幕1区 | 欧美综合国产精品久久丁香 | 日韩高清电影 | 国产一区二区三区四区 | 国产成人精品综合 | 欧美日韩免费 | 手机三级电影 | 国产精品久久久久久久午夜 | 天堂一区二区三区 | 欧美一区二区三区在线免费观看 | 91久久久久久 | 日韩视频一区二区 | 激情亚洲 | 国产999精品久久久久久绿帽 | 第四色狠狠 | 91视频在线看 | 成人国产精品免费观看视频 | 亚洲精品一区二区在线 | 久久精品欧美一区二区三区不卡 | 午夜免费电影 | 亚洲视频二区 | 日韩一区二区不卡 | 婷婷久久网 | 久久大陆| 成人免费视频网站在线看 | 琪琪午夜伦伦电影福利片 | 欧美日韩在线精品 | 成人av电影在线观看 | 国产999精品久久久久久 | 欧美激情久久久 | 日韩在线中文字幕 | 麻豆久久 | 国产成人久久精品一区二区三区 | 久久亚洲一区二区三区四区 | 亚洲网站在线 | 国产一区二区三区在线观看免费 | 91视频精选 | 一级黄色淫片 | 农村黄性色生活片 | 综合亚洲视频 |