spring mvc 判断用户使用的android 手机还是iphone

   最近刚好有一个合作客户在问,能不能根据不同的手机系统用户来自动下载不同的APP。

由于客户只有一个客户端,所以暂时也不考虑批量的问题。

主要是通过http头信息中的user-agent域来识别。

@RequestMapping(value="welcome",method=RequestMethod.GET)
	public String welcome1(@RequestHeader(value="User-Agent") String userAgent) {
		
		if(userAgent.contains("Linux"))
		{
			return "welcomeToLinux";
		}
		else if(userAgent.contains("iPhone"))
		{
			return "welcomeToIos";
		}
		else if(userAgent.contains("Android"))
		{
			return "welcomeToAndroid";
		}
		return "welcome";
		
	}

猜你喜欢

转载自blog.csdn.net/zyfzhangyafei/article/details/88945878