基于 http 请求在 Web 应用程序中检测移动浏览器的标准方法 [英] Standard way to detect mobile browsers in a web application based on the http request

查看:21
本文介绍了基于 http 请求在 Web 应用程序中检测移动浏览器的标准方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们开始为企业电子商务 Web 应用程序(基于 Java/Servlet)提供移动浏览器支持.当然要做出很多决定,但在我看来,基石是能够可靠地检测移动浏览器,并相应地对要返回的内容做出决定.是否有标准方法可以根据 http 请求(快速)做出此决定,并且最好收集有关发出请求的给定浏览器和设备的更多信息(屏幕尺​​寸、html 功能等?).

We are beginning to go down the path of mobile browser support for an enterprise e-commerce webapp (Java/Servlet based). Of course there are many decisions to be made, but it seems to me the cornerstone is to be able to reliably detect mobile browsers, and make decisions on the content to be returned accordingly. Is there a standard way to make this determination (quickly) based on the http request, and ideally glean more information about the given browser and device making the request (screen size, html capabilities, etc?).

如果有人走上这条道路,即采用现有的大型企业 Web 应用程序并从开发端构建移动浏览器支持,我也会很感激他们提供的任何有用的补充信息.

I would also appreciate any supplemental information that would be of use from someone who has gone down this path of taking an existing large scale enterprise webapp and architect-ing out mobile browser support from the development side.

[edit] 我当然了解请求标头和有关标准用户代理数据库的信息是一个很大的帮助.对于那些谈论其他"请求标头属性的人,如果您可以包含类似的标准化名称/值资源,那将会有很大帮助.

[edit] I certainly understand the request header and the information about a database of standard user agents is a great help. For those talking about 'other' request header properties, if you could include similar standardized name / resource of values that would be a big help.

一些用户提出了一些解决方案,这些解决方案涉及通过线路调用某些将进行检测的 Web 服务.虽然我确信这有效,但它对于企业电子商务网站来说不是一个好的解决方案,原因有两个:1) 速度.对第三方的每个页面请求通过线路调用都会对性能产生巨大影响.2) 依赖/法律.我们会将我们的网站响应时间和关键功能与其服务联系起来,出于法律和风险原因,这很糟糕.

[edit] Several users have proposed solutions that involve a call over the wire to some web service that will do the detection. While I'm sure this works, it is not a good solution for an enterprise e-commerce site for two reasons: 1) speed. A call over the wire for every page request to a third party would have huge performance implications. 2) dependency/legal. We'd tie our website response time and key functionality to their service, which is horrible for legal and risk reasons.

推荐答案

标准的方式不是检查用户代理吗?这是一个用户代理数据库,可用于检测移动浏览器.

Wouldn't the standard way be to check the user agent? Here's a database of user agents you can use to detect mobile browsers.

这篇关于基于 http 请求在 Web 应用程序中检测移动浏览器的标准方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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