Spring WebFlux 返回html文件
spring5开始推出了 reactive web的非阻塞式编程,可以用于替代Spring MVC。本着好奇的心态尝试使用了一波,在访问请求返回html文件时,遇到了一些困扰,现在在此记录。
1、通过资源的方式返回
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;