// Path: src/main/java/com/baicai/core/Constant.java
// public interface Constant {
// 	public static final String CHARSET = "UTF-8";
//     public static final int CONCURRENT_CAPACITY_SIZE = 500;
//     public static final int LOCKER_SLEEP_UNIT_TIME = 20;
// 
//     public static final int BUFFER_BYTE_SIZE = 8192;
//     public static final String DOT=".";
//     public static final String NULL = "null";
//     public static final String SPACE = " ";
//     public static final String QUOTE = "\"";
//     public static int ioBufferSize = 16384;
//     
//     public static final String USER_SALT=PropertiesTool.get("system", "USER_SALT");
// }


import java.beans.PropertyEditorSupport;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ui.Model;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.util.HtmlUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baicai.core.Constant;

	/**
	 * 客户端返回字符串
	 * 
	 * @param response
	 * @param string
	 * @return
	 */
	protected String renderString(HttpServletResponse response, String string, String type) {
		try {
			response.reset();
			response.setContentType(type);
			response.setCharacterEncoding("utf-8");
			response.getWriter().print(string);
			return null;
		} catch (IOException e) {
			return null;
		}
	}
	
	protected boolean isAjax(HttpServletRequest request){
		boolean isAjax = "XMLHttpRequest".equals(request.getHeader("X-Requested-With"));
		return isAjax;
	}
	
	@InitBinder
	protected void initBinder(WebDataBinder binder) {
		// String类型转换，将所有传递进来的String进行HTML编码，防止XSS攻击
		binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
			@Override
			public void setAsText(String text) {

// Path: src/main/java/com/baicai/core/Constant.java
// public interface Constant {
// 	public static final String CHARSET = "UTF-8";
//     public static final int CONCURRENT_CAPACITY_SIZE = 500;
//     public static final int LOCKER_SLEEP_UNIT_TIME = 20;
// 
//     public static final int BUFFER_BYTE_SIZE = 8192;
//     public static final String DOT=".";
//     public static final String NULL = "null";
//     public static final String SPACE = " ";
//     public static final String QUOTE = "\"";
//     public static int ioBufferSize = 16384;
//     
//     public static final String USER_SALT=PropertiesTool.get("system", "USER_SALT");
// }


// Path: src/main/java/com/baicai/controller/common/BaseController.java
import java.beans.PropertyEditorSupport;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ui.Model;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.util.HtmlUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baicai.core.Constant;

	/**
	 * 客户端返回字符串
	 * 
	 * @param response
	 * @param string
	 * @return
	 */
	protected String renderString(HttpServletResponse response, String string, String type) {
		try {
			response.reset();
			response.setContentType(type);
			response.setCharacterEncoding("utf-8");
			response.getWriter().print(string);
			return null;
		} catch (IOException e) {
			return null;
		}
	}
	
	protected boolean isAjax(HttpServletRequest request){
		boolean isAjax = "XMLHttpRequest".equals(request.getHeader("X-Requested-With"));
		return isAjax;
	}
	
	@InitBinder
	protected void initBinder(WebDataBinder binder) {
		// String类型转换，将所有传递进来的String进行HTML编码，防止XSS攻击
		binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
			@Override
			public void setAsText(String text) {

				setValue(text == null ? null : HtmlUtils.htmlEscape(text,Constant.CHARSET));
