作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望我的jsp页面向用户显示操作系统信息。
最佳答案
服务器端操作系统信息
JSP是java,可以找到它正在执行的计算机的操作系统。我们可以使用 getProperty() 方法来查找系统的系统属性。它返回一个带有操作系统名称的字符串。它支持java中的各种操作系统。
示例:
<%@ page language="java"%>
<html>
<head>
<title>Example for Printing the OS name</title>
</head>
<body>
<%
out.println("OS: " + System.getProperty("os.name"));
%>
</body>
</html>
客户端信息
String agent = request.getHeader ("user-agent");
StringTokenizer st = new StringTokenizer (agent ,";");
st.nextToken ();
// Get the user's browser name
String userBrowser = st.nextToken ();
// Get the user's operating system name
String userOs = st.nextToken ();
关于java - 如何在JSP中显示操作系统信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4117536/
我是一名优秀的程序员,十分优秀!