我正在尝试使用以下代码获取servlet中客户端的操作系统名称:
public class SomeServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String userAgentString = request.getHeader("User-Agent");
UserAgent userAgent = UserAgent.parseUserAgentString(userAgentString);
OperatingSystem os = userAgent.getOperatingSystem();
}
}
我收到错误UserAgent无法解析为某种类型。我该如何解决这个问题?