如何使用Webflux提供静态内容? [英] How to serve static content using Webflux?
本文介绍了如何使用Webflux提供静态内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习webflux,我想知道如何使用webflux在MicroService上提供静态内容,但是我没有找到相关信息.
I am learning webflux and I would like to know how to serve static content on a MicroService using webflux but I didn´t find information to do it.
推荐答案
尝试一下
RouterFunction router = resources("/**", new ClassPathResource("public/"));
更新:当从外部访问静态文件时,不要忘记在URL中指定其名称,例如localhost:8080/index.html
UPDATE: Don't forget to specify a name of the static file in the URL when accessing it from outside, like localhost:8080/index.html
这篇关于如何使用Webflux提供静态内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文