如何在JSF应用程序中检测客户端区域设置? [英] How to detect client locale in JSF application?

查看:124
本文介绍了如何在JSF应用程序中检测客户端区域设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的代码中没有 Servlet ,那么如何在JSF应用程序中使用 ServletRequest.getLocale()是由JSF实现提供的?我正在尝试使用 ServletContextListener ,但是可以从 ServletContextEvent <到达 ServletRequest / code>?



无论如何,正确的做法是什么?

解决方案

  FacesContext.getCurrentInstance()getExternalContext()getRequestLocale(); 


How can I use ServletRequest.getLocale() in JSF application, when Servlet is absent in my code and is provided by JSF implementation? I'm trying to use ServletContextListener, but is it possible to reach ServletRequest from ServletContextEvent?

Anyway, what is the correct approach?

解决方案

FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();

?

这篇关于如何在JSF应用程序中检测客户端区域设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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