spring-boot-starter-webflux不能使用AcceptHeaderLocaleResolver [英] spring-boot-starter-webflux can't use AcceptHeaderLocaleResolver

查看:49
本文介绍了spring-boot-starter-webflux不能使用AcceptHeaderLocaleResolver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

spring-boot-starter-webflux不能使用org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver

那么spring-boot-starter-webflux如何使用resolveLocale?换句话说,反应堆中有什么与resolveLocale类似的东西?

解决方案

Spring WebFlux默认配置和使用 org.springframework.web.server.i18n.LocaleContextResolver (使用 org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver org.springframework.web.server.i18n.FixedLocaleContextResolver 作为实现).

您可以注入 java.util.Locale 作为Controller参数(如果使用的是Spring WebFlux的注释变体),或者注入并使用配置的 LocaleContextResolver > bean并直接使用.

spring-boot-starter-webflux can not use org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver

so how can spring-boot-starter-webflux use resolveLocale?In other words, what is there in reactor that is similar to resolveLocale?

解决方案

Spring WebFlux is configuring and using by default a org.springframework.web.server.i18n. LocaleContextResolver (with org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver and org.springframework.web.server.i18n.FixedLocaleContextResolver as implementations).

You can inject the java.util.Locale as a Controller argument (if you're using the annotation variant of Spring WebFlux), or inject and use the configured LocaleContextResolver bean and use it directly.

这篇关于spring-boot-starter-webflux不能使用AcceptHeaderLocaleResolver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆