Пытаемся отправить форму с файлом на сервер. То, что сработает в Chrome, в IE выдаст предупреждение: "Verifying application requirements. This may take a few moments." Но почему?
В IE8 невозможно без дополнительных программ посмотреть, какие заголовки содержит request/response. Поэтому установим Fiddler2.
http://localhost:8080/ -> http://localhost.:8080/
Оказалось, что IE8 устанавливает заголовок запроса Content-Type в application/x-ms-application. Этот же заголовок возвращается в response. Необходимо установить заголовок ответа в text/html.
Но, о ужас.
не работает!
В IE8 невозможно без дополнительных программ посмотреть, какие заголовки содержит request/response. Поэтому установим Fiddler2.
Fiddler is a Web Debugging Proxy which logs allКак отследить запросы к локальному web серверу? Надо добавить в адрес символ ".":HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect traffic, set breakpoints, and "fiddle" with incoming or outgoing data.
http://localhost:8080/ -> http://localhost.:8080/
Оказалось, что IE8 устанавливает заголовок запроса Content-Type в application/x-ms-application. Этот же заголовок возвращается в response. Необходимо установить заголовок ответа в text/html.
Но, о ужас.
@RequestMapping(value="/image", method=RequestMethod.POST)
@ResponseBody
public String uploadPicture(
HttpServletRequest request, HttpServletResponse response) {
response.setContentType("tetx/html; charset=utf-8");
не работает!
Google подсказал следующее решение проблемы:
@RequestMapping(value="/image", method=RequestMethod.POST)
public ResponseEntity<String> uploadPicture(
HttpServletRequest request, HttpServletResponse response, ... {
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.add("Content-Type", "text/html; charset=utf-8");
String result = null;
...
return new ResponseEntity<String>(result , responseHeaders, HttpStatus.CREATED);
}
Comments
Post a Comment