1.通过登录url获取域名:例如:http://www.bfec.com.cn:8080/bfec/admin:则s=www.bfec.com.cn

    private String getHost(String url){
        String s = "";
        Pattern p = Pattern.compile("(?<=//|)((\\w)+\\.)+\\w+");
        Matcher m = p.matcher(url);
        if(m.find()){
            s = m.group();
        }
        return s;
    }

2.获取uri;设置不缓存

注:如上1所示的url:则uri="/bfec/admin/"

        HttpServletRequest request = (HttpServletRequest) req;
        String uri = request.getRequestURI();//获取工程以后的路径
        //设置不缓存
        HttpServletResponse response = (HttpServletResponse) response1;
        response.setHeader("Cache-Control", "no-store");
        response.setHeader("Pragrma", "no-cache");
        response.setDateHeader("Expires", 0);
        
        StringBuffer url = request.getRequestURL();
        //获取域名,如:www.bfec.com.cn
        String tempContextUrl = this.getHost(url.toString());

 

posted on 2013-04-18 10:14  小写K  阅读(556)  评论(0编辑  收藏  举报