We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
作为服务端,客户端传递过来中文字符串以GBK编码,接口默认按utf-8接收到了,我如何按GBK编码获取数据呢
The text was updated successfully, but these errors were encountered:
如果你是通过MessageConverter解析的数据,在convert方法识别客户端数据编码:
convert
@Converter public class AppMessageConverter implements MessageConverter { ... @Nullable @Override public <T> T convert(@NonNull InputStream stream, @Nullable MediaType mediaType, Type type) throws IOException { Charset charset = mediaType == null ? null : mediaType.getCharset(); if (charset == null) { return JsonUtils.parseJson(IOUtils.toString(stream), type); } return JsonUtils.parseJson(IOUtils.toString(stream, charset), type); } }
如果没有使用使用MessageConverter,在你api对应的方法中拿到HttpRequest后自行转换:
@RestController class TestController { @RequestMapping( path = "/testCharset", method = {RequestMethod.POST}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) Object testCharset(HttpRequest request) { ... }
Sorry, something went wrong.
No branches or pull requests
作为服务端,客户端传递过来中文字符串以GBK编码,接口默认按utf-8接收到了,我如何按GBK编码获取数据呢
The text was updated successfully, but these errors were encountered: