Home | 简体中文 | 繁体中文 | 杂文 | 知乎专栏 | Github | OSChina 博客 | 云社区 | 云栖社区 | Facebook | Linkedin | 视频教程 | 打赏(Donations) | About
知乎专栏多维度架构

16.3. Could not read document: Invalid UTF-8 middle byte 0xd0

Spring 默认不支持 UTF-8

		
2016-08-17 16:04:53.148 WARN 7700 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message:	org.springframework.http.converter.HttpMessageNotReadableException:Could not read document: Invalid UTF-8 middle byte 0xd0 at [Source: java.io.PushbackInputStream@33aa54cc; line: 1, column: 38](through reference chain: api.domain.oracle.Withdraw["bankname"]); nested exception is 	com.fasterxml.jackson.databind.JsonMappingException: Invalid UTF-8 middle byte 0xd0 at [Source: java.io.PushbackInputStream@33aa54cc; line: 1, column: 38]
			(through reference chain: api.domain.oracle.Withdraw["bankname"])
		
		

解决方案 application.properties 配置文件中加入如下配置:

			spring.messages.encoding=UTF-8
			server.tomcat.uri-encoding=UTF-8
			spring.http.encoding.charset=UTF-8
			spring.http.encoding.enabled=true
			spring.http.encoding.force=true