antMatcher와 mvcMatcher의 차이
무엇이 다른가?HttpSecurity
의antMatcher()
그리고.mvcMatcher()
함수?
언제 그것들을 사용해야 하는지 설명해 줄 수 있는 사람이 있습니까?
이 방법의 서명이 공식 문서에도 명시되어 있음을 분명히 알 수 있듯이,
antMatcher(String antPattern)
를 구성할 수 있습니다.HttpSecurity
제공된 개미 패턴과 일치하는 경우에만 호출됩니다.
mvcMatcher(String mvcPattern)
를 구성할 수 있습니다.HttpSecurity
제공된 Spring MVC 패턴과 일치하는 경우에만 호출됩니다.
일반적으로.mvcMatcher
보다 안전합니다.antMatcher
예를 들어,
antMatchers("/secured")
정확한 것만 일치합니다./secured
URLmvcMatchers("/secured")
성냥/secured
게다가/secured/
,/secured.html
,/secured.xyz
따라서 보다 일반적이며 몇 가지 가능한 구성 오류도 처리할 수 있습니다.
mvcMatcher
Spring MVC가 매칭에 사용하는 것과 동일한 규칙을 사용합니다(사용 시).@RequestMapping
주석).
Spring MVC에서 현재 요청이 처리되지 않을 경우 패턴을 개미 패턴으로 사용하는 합리적인 기본값이 사용됩니다.출처
라고 덧붙일 수도 있습니다.mvcMatchers
API(4.1.1 이후)가 다음보다 최신입니다.antMatchers
API(3.1 이후).
AntMatcher()
는 Ant-style 경로 패턴에 대한 구현입니다.이 매핑 코드의 일부는 Apache Ant에서 친절하게 차용되었습니다.
MvcMatcher()
Spring MVC 사용HandlerMappingIntrospector
경로를 일치시키고 변수를 추출합니다.
그래서 그들은 둘 다RequestMatcher
인터페이스를 사용하지만 후드 아래에서 다른 표현 언어를 사용합니다.
antMatcher("/users/**") matches any path starting with /users
antMatchers("/users") matches only the exact /users URL
mvcMatchers("/users") matches /users, /users/, /users.html
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/users/movie/**") // matches any path starting with /users/movie
.hasRole("ADMIN") ...
}
}
언급URL : https://stackoverflow.com/questions/50536292/difference-between-antmatcher-and-mvcmatcher
'sourcecode' 카테고리의 다른 글
요소에 여러 개의 CSS 전환을 갖는 방법은 무엇입니까? (0) | 2023.08.16 |
---|---|
iphone/ipad(실제 장치, 시뮬레이터 없음)의 문서 폴더에 액세스하는 방법이 있습니까? (0) | 2023.08.16 |
Array.PowerShell 어레이 찾기 (0) | 2023.08.16 |
고정 영역을 제외한 전체 화면을 어둡게 합니까? (0) | 2023.08.16 |
웹킷을 C/C++/Win32 응용 프로그램에 내장하는 방법은 무엇입니까? (0) | 2023.08.16 |