判断请求来源是否PC
判断请求是否来自Windows系统的PC端,可以通过解析HTTP请求头中的
User-Agent字段来实现,User-Agent是浏览器或客户端在请求中自动携带的标识字符串,包含了设备类型、操作系统、浏览器版本等信息。通过检测其中是否包含Windows系统的关键词,即可判断请求是否来自Windows PC。
["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod","OpenHarmony"
]
public static boolean isMobileDevice(String userAgent) { String[] mobileKeywords = {"Android", "iPhone", "iPad", "Mobile", "Windows Phone"}; if (userAgent == null) return false; String lowerUserAgent = userAgent.toLowerCase(); for (String keyword : mobileKeywords) { if (lowerUserAgent.contains(keyword.toLowerCase())) { return true; } } return false; }
linux下的docker操作命令及异常

浙公网安备 33010602011771号