sensor/WebRoot/CheckClient.jsp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
sensor/WebRoot/WEB-INF/web.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
sensor/src/com/fgkj/actions/CheckClientAction.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
sensor/src/struts.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
sensor/WebRoot/CheckClient.jsp
New file @@ -0,0 +1,34 @@ <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML> <html> <head> <base href="<%=basePath%>"> <title>正在进入</title> <META HTTP-EQUIV="Refresh" CONTENT="0;URL=CheckClientAction_check"> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> <link rel="stylesheet" href="css/login_layout.css"> </head> <body> <!-- 开机动画 <div class="start-animate" style="background-color:#e4e7eb"> <div class="animate-contain"> <img src="image/loading-open.gif" alt=""> </div> </div> --> </body> </html> sensor/WebRoot/WEB-INF/web.xml
@@ -80,8 +80,11 @@ <listener> <listener-class>com.fgkj.Listeners.Sessionlister</listener-class> </listener> <welcome-file-list> <!-- <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> --> <welcome-file-list> <welcome-file>CheckClient.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>Faces Servlet</servlet-name> sensor/src/com/fgkj/actions/CheckClientAction.java
New file @@ -0,0 +1,44 @@ package com.fgkj.actions; import javax.servlet.http.HttpSession; import com.fgkj.dao.CheckMobile; public class CheckClientAction extends ActionUtil{ /** * 检查访问方式是否为移动端 * * @Title: check * @Date : 2014-7-7 下午03:55:19 * @param request * @throws IOException */ public String check(){ boolean isFromMobile=false; HttpSession session= getSession(); //检查是否已经记录访问方式(移动端或pc端) //if(null==session.getAttribute("ua")){ try{ //获取ua,用来判断是否为移动端访问 String userAgent = getRequest().getHeader( "USER-AGENT" ).toLowerCase(); if(null == userAgent){ userAgent = ""; } isFromMobile=CheckMobile.check(userAgent); //判断是否为移动端访问 if(isFromMobile){ // System.out.println("移动端访问"); //session.setAttribute("ua","mobile"); return SUCCESS; } else { //System.out.println("pc端访问"); //session.setAttribute("ua","pc"); return NONE; } }catch(Exception e){} //} return NONE; } } sensor/src/struts.xml
@@ -12,6 +12,11 @@ <package name="default" namespace="/" extends="json-default" > <action name="CheckClientAction_check" class="com.fgkj.actions.CheckClientAction" method="check"> <result name="none" type="redirect">/index.html</result> <result name="success" type="redirect">/mobile/index.html</result> </action> <action name="*!*" class="com.fgkj.actions.{1}" method="{2}"> <result type="json"></result> </action>