---
title: "aaaa"
author: "pure1202"
date: "2010-09-06T11:59:32Z"
tags: []
categories: ["企业架构"]
slug: "aaaa"
draft: false
lastmod: "2010-09-06T11:59:32Z"
id: 756507
url: "https://aijof.iteye.com/blog/756507"
---

```java

String str1 = HtmlUtils.htmlEscape(specialStr);// ①转换为HTML转义字符表示
String str2 = HtmlUtils.htmlEscapeDecimal(specialStr);// ②转换为数据转义表示 
String str3 = HtmlUtils.htmlEscapeHex(specialStr); //③转换为十六进制数据转义表示 
 // 对转义后字符串进行反向操作 
System.out.println(HtmlUtils.htmlUnescape(str1)); 

@SuppressWarnings("unchecked")
	public void doFilter(ServletRequest req, ServletResponse res,
			FilterChain chain) throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest) req;
	    Map map = request.getParameterMap();
	    Set set = map.entrySet();
	    if(map!= null){
	    	for(Iterator it = set.iterator();it.hasNext();){
	    	Map.Entry entry = (Map.Entry) it.next();
	    	if(entry.getValue() instanceof String[]){
	    		String[] values = (String[]) entry.getValue();
	    		for(int i = 0 ; i < values.length ; i++){
	    			values[i] = HtmlUtils.htmlEscape(values[i]);
	    		}
	    		entry.setValue(values);
	    	}
	    }
		chain.doFilter(req, res);
	   }
	}

```