简体   繁体   English

如何识别来自PDA /台式机/服务器的Web请求?

[英]How to identify Web request from PDA/Desktop/Server?

I would like to know if is possible to identify (with JAVA) the kind of computer used to make a request, for example: Server, desktop, PDA (tablet,cellphone,etc)? 我想知道是否可以(使用JAVA)识别用于发出请求的计算机类型,例如:服务器,台式机,PDA(平板电脑,手机等)?

Thank you! 谢谢!

Depends on what are you using to accept requests. 取决于您使用什么来接受请求。 For http requests, informations are in User agent section of request header. 对于http请求,信息位于请求标头的“用户代理”部分。

Yes it is to a degree. 是的,在一定程度上。 You have to get the User-Agent string from the HTTP request. 您必须从HTTP请求中获取User-Agent字符串。 How to do that will depend on your Java and framework implementation but that's the direction you should take. 如何执行将取决于您的Java和框架实现,但这是您应该采取的方向。 You will have to examin the string for browser versions, mobile, etc... 您必须检查浏览器版本,移动设备等的字符串...

Here is the request from my Mac: 这是我的Mac发出的请求:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1

And here from my Windows server: 在我的Windows服务器上:

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)

And here from my iPhone: 在我的iPhone上:

Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8536.25

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM