Path Matching

Dev.Hammy·2024년 4월 8일
0

반응형 스택에서 이에 상응하는 내용 보기

path matching 및 URL 처리와 관련된 옵션을 사용자 정의할 수 있습니다. 개별 옵션에 대한 자세한 내용은 PathMatchConfigurer javadoc를 참조하세요.

다음 예에서는 Java 구성에서 path matching를 사용자 정의하는 방법을 보여줍니다.

@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {

	@Override
	public void configurePathMatch(PathMatchConfigurer configurer) {
		configurer.addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController.class));
	}

	private PathPatternParser patternParser() {
		// ...
	}
}

다음 예에서는 XML 구성에서 path matching를 사용자 정의하는 방법을 보여줍니다.

<mvc:annotation-driven>
	<mvc:path-matching
		path-helper="pathHelper"
		path-matcher="pathMatcher"/>
</mvc:annotation-driven>

<bean id="pathHelper" class="org.example.app.MyPathHelper"/>
<bean id="pathMatcher" class="org.example.app.MyPathMatcher"/>

0개의 댓글