当前位置:网站首页>利用请求头开发多端应用
利用请求头开发多端应用
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端
移动端
边栏推荐
- Wechat H5 official account to get openid climbing account
- [牛客网刷题 Day4] JZ55 二叉树的深度
- 多元线性回归(sklearn法)
- 12. Dynamic link library, DLL
- Programming implementation of ROS learning 6 -service node
- Halcon shape_ trans
- [code practice] [stereo matching series] Classic ad census: (4) cross domain cost aggregation
- Use arm neon operation to improve memory copy speed
- . Net service governance flow limiting middleware -fireflysoft RateLimit
- Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding
猜你喜欢

What is a firewall? Explanation of basic knowledge of firewall

Ros-10 roslaunch summary

Huber Loss

Solutions of ordinary differential equations (2) examples

嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!

Attention is all you need

Applet (global data sharing)

Confusion matrix

Applet (subcontracting)
![Rebuild my 3D world [open source] [serialization-3] [comparison between colmap and openmvg]](/img/7d/e7370e757c18b3dbb47e633703c346.jpg)
Rebuild my 3D world [open source] [serialization-3] [comparison between colmap and openmvg]
随机推荐
Pearson correlation coefficient
Multiple linear regression (gradient descent method)
Use and programming method of ros-8 parameters
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
scipy. misc. imread()
fs. Path module
Driver's license physical examination hospital (114-2 hang up the corresponding hospital driver physical examination)
kubeadm系列-01-preflight究竟有多少check
嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!
np. allclose
Configuration and startup of kubedm series-02-kubelet
Multiple solutions to one problem, asp Net core application startup initialization n schemes [Part 1]
How many checks does kubedm series-01-preflight have
nodejs_ 01_ fs. readFile
Install the CPU version of tensorflow+cuda+cudnn (ultra detailed)
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition
深入浅出PyTorch中的nn.CrossEntropyLoss
. Net service governance flow limiting middleware -fireflysoft RateLimit
12、动态链接库,dll
Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software




