ajax submit 在IE下提示下载

转载自:http://ldzyz007.iteye.com/blog/2068440

1.修改: contentType 为text/html 


2.注解修改如下: 
@RequestMapping(value = "/save", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")  
@ResponseBody 

改为 
@RequestMapping(value = "/save", method = RequestMethod.POST, produces = "text/htm;charset=UTF-8")  
@ResponseBody 

3.其他解决方法(本人没用到): 
在IE9下,将json字符串用下面的格式返回给客户端 
<body> 
<pre>{"message":"保存成功","data":null,"success":true}</pre> 

</body> 

本人部分代码如下:

@RequestMapping(value = "/importExcel/check", method = RequestMethod.POST,produces = "text/htm;charset=UTF-8")
	@ResponseBody
	public Result importExcelView(MultipartFile file,HttpServletResponse response) throws Exception {
		
		response.setContentType("text/html;charset=utf-8");

补充:

发现返回数据为:

<h1>HTTP Status 406 - </h1><hr size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().</u></p><hr size="1" noshade="noshade"><h3>Apache Tomcat/7.0.26</h3>

解决办法:将 返回 类型 Result 改为 String 类型。


猜你喜欢

转载自blog.csdn.net/lishk314/article/details/52764756