java 判断浏览器

String agent
agent = request.getHeader("USER-AGENT");   
    log.debug("--------------------agent==========" + agent);
    
   if (null != agent && -1 != agent.indexOf("MSIE")) { 
    response.addHeader("Content-Disposition","attachment; filename=\"" + java.net.URLEncoder.encode(fileName, "UTF-8").replace("+", " ") + "\"");
  } else  if (null != agent && -1 != agent.indexOf("Firefox")) { 
    response.addHeader("Content-Disposition","attachment; filename=\"" + new String(fileName.getBytes("UTF-8"), "iso8859-1") + "\"");
   } else  if (null != agent && -1 != agent.indexOf("Safari")) { 
    response.addHeader("Content-Disposition","attachment; filename=\"" + java.net.URLEncoder.encode(fileName, "UTF-8").replace("+", " ") + "\"");
  } else {
    
   }
posted @ 2008-07-17 17:15  南守拥  阅读(734)  评论(0编辑  收藏  举报