解決各瀏覽器向url中傳中問參數的問題

http://www.javashuo.com/article/p-bqnmvgum-bn.htmlhtml

後臺的處理代碼java

public static String getUrlnewName( String oldName) {
		String newName = "";
		try {
			String agent = inv.getRequest().getHeader("USER-AGENT");
			if (null != agent) {
				boolean isMSIE = (StringUtils.isNotBlank(agent) && agent.indexOf("MSIE") != -1);
				if (-1 != agent.indexOf("Firefox")) {// Firefox
					newName = "=?UTF-8?B?" + (new String(Base64.encodeBase64(oldName.getBytes("UTF-8")))) + "?=";
				} else if (isMSIE) { // IE 9 以上版本
					newName = oldName;
				} else {
					newName = URLEncoder.encode(oldName, "UTF-8");
					newName = StringUtils.replace(newName, "+", "%20");// 替換空格
				}
			} else {
				newName = oldName;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return newName;
	}
相關文章
相關標籤/搜索