当前位置:网站首页>利用请求头开发多端应用
利用请求头开发多端应用
2022-07-05 09:03:00 【緈福的街口】
servlet页面
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);
}
}
网页效果
PC端
移动端
边栏推荐
- LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
- Applet (global data sharing)
- Halcon Chinese character recognition
- scipy.misc.imread()
- js异步错误处理
- My experience from technology to product manager
- asp.net(c#)的货币格式化
- Mengxin summary of LIS (longest ascending subsequence) topics
- 520 diamond Championship 7-4 7-7 solution
- It cold knowledge (updating ing~)
猜你喜欢

Confusion matrix

牛顿迭代法(解非线性方程)

Introduction Guide to stereo vision (1): coordinate system and camera parameters

It cold knowledge (updating ing~)
![[牛客网刷题 Day4] JZ55 二叉树的深度](/img/f7/ca8ad43b8d9bf13df949b2f00f6d6c.png)
[牛客网刷题 Day4] JZ55 二叉树的深度

Install the CPU version of tensorflow+cuda+cudnn (ultra detailed)

RT thread kernel quick start, kernel implementation and application development learning with notes

Redis implements a high-performance full-text search engine -- redisearch

Beautiful soup parsing and extracting data

Generate confrontation network
随机推荐
np. allclose
牛顿迭代法(解非线性方程)
Multiple solutions to one problem, asp Net core application startup initialization n schemes [Part 1]
File server migration scheme of a company
图解网络:什么是网关负载均衡协议GLBP?
Understanding rotation matrix R from the perspective of base transformation
uni-app 实现全局变量
fs. Path module
Halcon blob analysis (ball.hdev)
scipy. misc. imread()
Introduction Guide to stereo vision (5): dual camera calibration [no more collection, I charge ~]
多元线性回归(sklearn法)
AUTOSAR从入门到精通100讲(103)-dbc文件的格式以及创建详解
Introduction Guide to stereo vision (7): stereo matching
Use arm neon operation to improve memory copy speed
.NET服务治理之限流中间件-FireflySoft.RateLimit
Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
c#比较两张图像的差异
Codeforces round 684 (Div. 2) e - green shopping (line segment tree)
ROS learning 4 custom message




