티스토리 뷰
spring application과 vue를 같은 프로젝트로 배포할 때 vue history mode로 설정하고 spring application은 아래와 같이 설정해줘야됨.
@Component
@Order(-2)
public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler {
public GlobalErrorWebExceptionHandler(ErrorAttributes errorAttributes, WebProperties.Resources resources, ApplicationContext applicationContext
, ServerCodecConfigurer serverCodecConfigurer) {
super(errorAttributes, resources, applicationContext);
super.setMessageWriters(serverCodecConfigurer.getWriters());
super.setMessageReaders(serverCodecConfigurer.getReaders());
}
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(
ErrorAttributes errorAttributes) {
return RouterFunctions.route(
RequestPredicates.all(), this::renderErrorResponse);
}
private Mono<ServerResponse> renderErrorResponse(
ServerRequest request) {
return ServerResponse.status(HttpStatus.OK)
.contentType(MediaType.TEXT_HTML)
.body(BodyInserters.fromResource(new ClassPathResource("/static/index.html")));
}
}
mvc 예제는 너무 많은데 webflux 예제는 확실히 적다.
반응형
댓글