SpringBoot+SpringSecurity 정적 자원 의 실현 을 차단 하지 않 습 니 다.
SpringBoot 에 SpringSecurity 를 추가 한 후에 정적 자원 이 항상 여과 되 어 인터페이스 가 보기 싫 습 니 다.
디 렉 터 리 구조:
2.문제 해결
정상적으로 자원 을 차단 하지 않 습 니 다.저 는 자 료 를 찾 아 보 겠 습 니 다.기본적으로 다시 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:
*/
@Configuration
public 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/**");
}
configure 를 설정 한 후 target 을 제거 해 야 합 니 다.그렇지 않 으 면 유효 하지 않 습 니 다.
여기 서 SpringBoot+SpringSecurity 가 정적 자원 의 실현 을 차단 하지 않 는 다 는 글 을 소개 합 니 다.더 많은 SpringBoot+SpringSecurity 가 정적 자원 을 차단 하지 않 는 다 는 내용 은 예전 의 글 을 검색 하거나 아래 의 관련 글 을 계속 찾 아 보 세 요.앞으로 저 희 를 많이 지지 해 주시 기 바 랍 니 다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
【Java・SpringBoot・Thymeleaf】 에러 메세지를 구현(SpringBoot 어플리케이션 실천편 3)로그인하여 사용자 목록을 표시하는 응용 프로그램을 만들고, Spring에서의 개발에 대해 공부하겠습니다 🌟 마지막 데이터 바인딩에 계속 바인딩 실패 시 오류 메시지를 구현합니다. 마지막 기사🌟 src/main/res...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.