网站首页  汉语字词  英语词汇  考试资料  写作素材

请输入您要查询的范文:

 

标签的border 样式在浏览器中显示不出来的解决方法
  • Date Line
  • dateline
  • date-line
  • date night
  • date-night
  • date of birth
  • date-of-birth
  • date palm
  • date-palm
  • date range
  • 就地正法
  • 就坐
  • 就学
  • 就寝
  • 就座
  • 就手
  • 就擒
  • 就教
  • 就是
  • 就木
  • 关于公布2013年宁波余姚市考录公务员考察对象的公告(四)
  • 韶关市2013年考试录用公务员体检结果公告(四)
  • 2013年黑龙江省公务员招考面试公告
  • 2013年汉中市城固县公开选拔副科级领导干部体检有关事项公告
  • 2013年深圳市宝安区竞争性选拔处级领导干部任职人选公告
  • 2013年阜阳市考录公务员入围体检人员名单
  • 汕头市机构编制委员会办公室2013年拟录用公务员公示
  • 中共汕头市委宣传部2013年拟录用公务员公示
  • 汕头市台湾同胞联谊会2013年拟录用参照公务员法管理机关人员公示
  • 汕头市金平区2013年拟录用公务员公示
  • 标题 jsp判断移动设备的正则
    分类 范文、应用文-IT技术专栏-脚本栏目
    范文
        天猫php判断移动设备的正则(个人猜测),觉得很好用,于是就决定移植到jsp里面,大家可以参考下
        看到了一篇很好的文章, 《在天猫,前端做什么?》,里面有天猫php判断移动设备的正则(个人猜测),觉得很好用,于是就决定移植到jsp里面。
        jsp文件名为 index.jsp,其实也可以使用过滤器来进行拦截,然后跳转到其他域名去。
        完整代码如下:
        代码如下:
        <import=java.util.regex.matcher%>
        < import=java.util.regex.pattern%>
        <%@ page language=java pageencoding=utf-8%>
        <%!
        // b 是单词边界(连着的两个(字母字符 与 非字母字符) 之间的逻辑上的间隔),
        // 字符串在编译时会被转码一次,所以是 b
        // b 是单词内部逻辑间隔(连着的两个字母字符之间的逻辑上的间隔)
        string phonereg = b(ip(hone|od)|android|opera m(ob|in)i
        +|windows (phone|ce)|blackberry
        +|s(ymbian|eries60|amsung)|p(laybook|alm|rofile/midp
        +|laystation portable)|nokia|fennec|htc[-_]
        +|mobile|up.browser|[1-4][0-9]{2}x[1-4][0-9]{2})b;
        string tablereg = b(ipad|tablet|(nexus 7)|up.browser
        +|[1-4][0-9]{2}x[1-4][0-9]{2})b;
        pattern phonepat = pattern.compile(phonereg, pattern.case_insensitive);
        pattern tablepat = pattern.compile(tablereg, pattern.case_insensitive);
        public boolean checkmobile(string useragent){
        if(null == useragent){
        useragent = ;
        }
        // 匹配
        matcher matcherphone = phonepat.matcher(useragent);
        matcher matchertable = tablepat.matcher(useragent);
        if(matcherphone.find() || matchertable.find()){
        return true;
        } else {
        return false;
        }
        }
        %>
        <%
        string path = request.getcontextpath();
        string basepath = request.getscheme()+://+request.getservername()+:+request.getserverport()+path+/;
        //
        string useragent = request.getheader( user-agent ).tolowercase();
        if(null == useragent){
        useragent = ;
        }
        if(checkmobile(useragent)){
        response.sendredirect(basepath+download.html);
        //request.getrequestdispatcher(/download.html).forward(request,response);
        } else {
        response.sendredirect(basepath+index.html);
        //request.getrequestdispatcher(/index.html).forward(request,response);
        }
        //
        %>
        <!doctype html>
        <html lang=zh-cn>
        <head>
        <base href=<%=basepath%>>
        <title>测试移动设备跳转</title>
        <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=测试,移动设备,跳转>
        <meta http-equiv=description content=测试移动设备跳转>
        <!--
        <link rel=stylesheet type=text/css href=styles.css>
        -->
        </head>
        <body>
        <div id=pagecontent style=min-height:500px;_height:500px;>
        正在运行!<br>
        </div>
        </body>
        </html>
    随便看

     

    客官网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

     

    Copyright © 2002-2024 cumcu.com All Rights Reserved
    更新时间:2026/6/29 18:18:36