我在java中编写了这段代码,以查看有关标头和不同服务器请求的信息。但是当我在eclipse浏览器中运行代码时,它会通过浏览器显示Mozilla Firefox。当我在chrome上运行时,它显示相同。此外,它没有提供正确的处理器信息,因为它显示AMD作为我的处理器,而我有英特尔。我正在使用tomcat和eclipse。
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Headers<hr/>");
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
String headerValue = request.getHeader(headerName);
out.print("Header Name : <em>" + headerName);
out.print("</em>, Header Value : <em>" + headerValue);
out.println("</em><br/>");
}
StringBuffer url = request.getRequestURL();
String uri = request.getRequestURI();
String host = url.substring(0, url.indexOf(uri));
out.println("Host : " + request.getServerName()+"</br>");
out.println("Port : " + request.getServerPort()+"</br>");
out.print("URL : "+host);
out.println(uri);
out.println(getServletContext().getServerInfo());
out.println(getServletContext().getRealPath(request.getServletPath()));
}
答案 0 :(得分:1)
因为eclipse浏览器使用mazilla核心(或者User-Agent这么说),那么处理器呢,我认为它只给你一个CPU架构,而不是真正的类型