当前位置: 代码迷 >> Web前端 >> 不同浏览器上文件上载,文件名编码有关问题
  详细解决方案

不同浏览器上文件上载,文件名编码有关问题

热度:4701   发布时间:2013-02-26 00:00:00.0
不同浏览器下文件下载,文件名编码问题

?

/**	 * deal with the fileName encode in the different browsers	 * @param request	 * @param fileName	 * @return	 * @throws UnsupportedEncodingException	 */	private String encodeFileName(HttpServletRequest request, String fileName)			throws UnsupportedEncodingException {		String agent = request.getHeader("USER-AGENT");		if (null != agent && -1 != agent.indexOf("MSIE")) {			return URLEncoder.encode(fileName, "UTF8").replace("+","%20");		} else if (null != agent && -1 != agent.indexOf("Mozilla")) {			return "=?UTF-8?B?"					+ (new String(Base64.encodeBase64(fileName							.getBytes("UTF-8")))) + "?=";		} else {			return fileName;		}	}

?

?

?

  相关解决方案