如何使用 JSF 2.0 显示浏览器名称和版本?
我只需要在用户主页的
上显示浏览器名称及其版本。我们可以通过 JSF 2.0 实现这一目标吗?
Mojarra 2.0.4 - Primefaces 2.2.1 - glassfish v3
I just need to display the browser name and its version on a <h:outputText/>
in the user's homepage. Can we achieve this via JSF 2.0?
Mojarra 2.0.4 - Primefaces 2.2.1- glassfish v3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将此方法放入您的 bean 中:
然后:
Put this method in your bean:
And then:
据我所知,没有任何 JSF 组件可以通过单个标签或其他东西来实现这一点。您能做的最简单的操作就是显示原始 HTTP
User-Agent
标头。这只是一个又大又难看的字符串,并不总是每个人都可以解读。
然而,有一些 API 可以将 HTTP
User-Agent
标头转换为可用信息,例如确切的浏览器品牌/版本和平台品牌/版本,例如 useragentstring.com。一旦借助此类 API 将
User-Agent
标头转换为可用部分,您就必须能够借助托管 bean 以通常的方式在 JSF 中显示感兴趣的部分。There are as far as I know no JSF components which does that with a single tag or something. The easiest what you can do is just displaying the raw HTTP
User-Agent
header.This is only a large and ugly string which is not always decipherable to everyone.
There are however APIs which can convert a HTTP
User-Agent
header into useable information, such as the exact browser make/version and platform make/version, such as useragentstring.com.Once converted the
User-Agent
header into useable parts with help of such an API, you must be able to display the parts of interest in JSF with help of a managed bean the usual way.