ajax后台跨域处理

前端之家收集整理的这篇文章主要介绍了ajax后台跨域处理前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
response.addHeader("Access-Control-Allow-Origin","*");	
PrintWriter writer = null;
try {
	writer = response.getWriter();
	String json = JsonUtils.writer().writeValueAsString(rs);//自己封装的bean转json格式的String
	writer.print(json); 
} catch (IOException e) {
	e.printStackTrace();
}finally{
	if(writer!=null){
		writer.close();
	}
}
原文链接:https://www.f2er.com/ajax/160561.html

猜你在找的Ajax相关文章