New file |
| | |
| | | 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; |
| | | } |
| | | }
|