当前位置:网站首页>Using request headers to develop multi terminal applications
Using request headers to develop multi terminal applications
2022-07-05 09:11:00 【The corner of fufu】
servlet page
package com.ssyt.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** * Servlet implementation class UserAgentServlet */
@WebServlet("/ua")
public class UserAgentServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/** * @see HttpServlet#HttpServlet() */
public UserAgentServlet() {
super();
// TODO Auto-generated constructor stub
}
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String userAgent = request.getHeader("User-Agent");
response.setContentType("text/html;charest=utf-8");
response.getWriter().println(userAgent);
String output="";
if(userAgent.indexOf("Windows NT")!=-1) {
output = "<h1>This is PC!</h1>";
}else if(userAgent.indexOf("iPhone")!=-1 || userAgent.indexOf("Android")!=-1) {
output = "<h1>This is Mobile!</h1>";
}
response.getWriter().println(output);
}
}
Web effect
PC End
Mobile
边栏推荐
- C#绘制带控制点的Bezier曲线,用于点阵图像及矢量图形
- AUTOSAR从入门到精通100讲(103)-dbc文件的格式以及创建详解
- Introduction Guide to stereo vision (3): Zhang calibration method of camera calibration [ultra detailed and worthy of collection]
- Pearson correlation coefficient
- Alibaba cloud sends SMS verification code
- [technical school] spatial accuracy of binocular stereo vision system: accurate quantitative analysis
- Newton iterative method (solving nonlinear equations)
- 容易混淆的基本概念 成员变量 局部变量 全局变量
- ORACLE进阶(三)数据字典详解
- Jenkins Pipeline 方法(函数)定义及调用
猜你喜欢

nodejs_ fs. writeFile

Use and programming method of ros-8 parameters

混淆矩阵(Confusion Matrix)

信息与熵,你想知道的都在这里了

C#【必备技能篇】ConfigurationManager 类的使用(文件App.config的使用)

Summary of "reversal" problem in challenge Programming Competition

Applet data attribute method

利用请求头开发多端应用

Add discount recharge and discount shadow ticket plug-ins to the resource realization applet
![3D reconstruction open source code summary [keep updated]](/img/ec/984aede7ef9e758abd52fb5ff4e144.jpg)
3D reconstruction open source code summary [keep updated]
随机推荐
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
Applet network data request
Oracle advanced (III) detailed explanation of data dictionary
nodejs_ fs. writeFile
Generate confrontation network
Huber Loss
[daiy4] copy of JZ35 complex linked list
Uni app implements global variables
Programming implementation of ROS learning 2 publisher node
ROS learning 4 custom message
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
Wxml template syntax
[code practice] [stereo matching series] Classic ad census: (6) multi step parallax optimization
LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
np.allclose
Understanding rotation matrix R from the perspective of base transformation
Programming implementation of ROS learning 5-client node
Global configuration tabbar
Introduction Guide to stereo vision (3): Zhang calibration method of camera calibration [ultra detailed and worthy of collection]
2011-11-21 training record personal training (III)



