Java-Class-C:org.springframework.http.converter.StringHttpMessageConverter
| ylbtech-Java-Class-C:org.springframework.http.converter.StringHttpMessageConverter |
| 1.返回顶部 |
| 2.返回顶部 |
| 3.返回顶部 |
| 4.返回顶部 |
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
// package org.springframework.http.converter; import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StreamUtils; public class StringHttpMessageConverter extends AbstractHttpMessageConverter<String> {
public static final Charset DEFAULT_CHARSET;
@Nullable
private volatile List<Charset> availableCharsets;
private boolean writeAcceptCharset; public StringHttpMessageConverter() {
this(DEFAULT_CHARSET);
} public StringHttpMessageConverter(Charset defaultCharset) {
super(defaultCharset, new MediaType[]{MediaType.TEXT_PLAIN, MediaType.ALL});
this.writeAcceptCharset = true;
} public void setWriteAcceptCharset(boolean writeAcceptCharset) {
this.writeAcceptCharset = writeAcceptCharset;
} public boolean supports(Class<?> clazz) {
return String.class == clazz;
} protected String readInternal(Class<? extends String> clazz, HttpInputMessage inputMessage) throws IOException {
Charset charset = this.getContentTypeCharset(inputMessage.getHeaders().getContentType());
return StreamUtils.copyToString(inputMessage.getBody(), charset);
} protected Long getContentLength(String str, @Nullable MediaType contentType) {
Charset charset = this.getContentTypeCharset(contentType);
return (long)str.getBytes(charset).length;
} protected void writeInternal(String str, HttpOutputMessage outputMessage) throws IOException {
HttpHeaders headers = outputMessage.getHeaders();
if (this.writeAcceptCharset && headers.get("Accept-Charset") == null) {
headers.setAcceptCharset(this.getAcceptedCharsets());
} Charset charset = this.getContentTypeCharset(headers.getContentType());
StreamUtils.copy(str, charset, outputMessage.getBody());
} protected List<Charset> getAcceptedCharsets() {
List<Charset> charsets = this.availableCharsets;
if (charsets == null) {
charsets = new ArrayList(Charset.availableCharsets().values());
this.availableCharsets = (List)charsets;
} return (List)charsets;
} private Charset getContentTypeCharset(@Nullable MediaType contentType) {
if (contentType != null && contentType.getCharset() != null) {
return contentType.getCharset();
} else if (contentType != null && contentType.isCompatibleWith(MediaType.APPLICATION_JSON)) {
return StandardCharsets.UTF_8;
} else {
Charset charset = this.getDefaultCharset();
Assert.state(charset != null, "No default charset");
return charset;
}
} static {
DEFAULT_CHARSET = StandardCharsets.ISO_8859_1;
}
}
| 5.返回顶部 |
| 6.返回顶部 |
![]() |
作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |
Java-Class-C:org.springframework.http.converter.StringHttpMessageConverter的更多相关文章
- 报错:org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
org.springframework.http.converter.json.MappingJacksonHttpMessageConverter 1.错误描述 严重: Servlet /hux ...
- 异常:org.springframework.http.converter.HttpMessageNotReadableException
spring(springboot.springmvc)出现标题的异常一般是由于controller的入参失败引起的. 介绍下常规入参的两种格式: ,这种方式的入参主要是接受key-value的参数, ...
- Spring整合Mybatis报 java.lang.ClassNotFoundException:org.springframework.core.metrics.ApplicationStartup,即:spring的版本过高,采用RELEASE稳定版
1.遇到的问题: 今天在弄spring整合mybatis的时候遇到一个小问题,如图所示: 简单来说:就是我的spring的xml文件没找到,我就奇了怪了,我所有的配置都没问题啊! 我pom.xml配置 ...
- SSM框架搭建java.lang.ClassNotFoundException: org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
在搭建 spring springMVC Mybatis 时候出错 将org.springframework.http.converter.json.MappingJacksonHttpMessage ...
- Java-Class-C:org.springframework.web.client.RestTemplate
ylbtech-Java-Class-C:org.springframework.web.client.RestTemplate 1.返回顶部 1. org.springframework.web.c ...
- SpringMVC分页查询无法直接将对象转换成json的解决办法(报org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type:错)
在用ajax获得分页数据时,无法将获取的值赋值给input标签,在修改用户信息时不显示用户已经注册的信息,百度可知 springmvc处理分页数据返回的对象时,无法直接将对象转换成json,会报org ...
- org.springframework.http.converter.HttpMessageNotReadableException
发起请求报错:org.springframework.http.converter.HttpMessageNotReadableException 查看请求头: application/json 所以 ...
- SSM报错:No converter found for return value of type: class java.util.ArrayList at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverter
我使用的是SSM框架,是在编写测试RESTFUL接口的时候出现, @RequestMapping(value = "/selectAll", method = RequestMet ...
- Spring 整合 Flex (BlazeDS)无法从as对象 到 Java对象转换的异常:org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.Date' to required type 'java.sql.Timestamp' for property 'wfsj'; nested exception is java.lang.Ill
异常信息如下: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value ...
随机推荐
- C#接口的作用实例解析
一.接口的作用: 我们定义一个接口: public interface IBark { void Bark(); } 1. 再定义一个类,继承于IBark,并且必需实现其中的Bark()方法 pub ...
- 【dart学习】-- Dart之元数据
一,概述 元数据概述 元数据(Metadata),又称中介数据.中继数据,为描述数据的数据(data about data),主要是描述数据属性(property)的信息,用来支持如指示存储位置.历 ...
- h5移动端局部放大效果
首先添加zoom.js (function (root, factory) { if (typeof exports === 'object' && typeof module === ...
- 一些DP杂题
1. [HNOI2001] 产品加工 一道简单的背包,然而我还是写了很久QAQ 时间范围是都小于5 显然考虑一维背包,dp[i]表示目前A消耗了i的最小B消耗 注意 if(b[i]) dp[j]=dp ...
- int在64位操作系统中占多少位?
仍然是32位. 曾经是这样的:16位操作系统中,int 占16位:在32位操作系统中,int 占32位.但是现在人们已经习惯了 int 占32位,因此在64位操作系统中,int 仍为32位.64位整型 ...
- java中的javap命令(工作中补充的知识)
背景: 上周针对某信得压力测试demo进行场景复现,但是只提供了class文件,只能通过反编译的软件进行查看,在复现的过程中报错某某某行,这里我以xx行代替,因为是class文件,所以并不能确定具体到 ...
- XML 扩展部分
引入命名空间 xmlns DTD缺点 1.不支持命名空间 2.支持的数据类型很少 3.DTD不可扩展 4.DTD不遵循XML规范 DTD的优点 简洁 schema 通过schema来解决DTD的不足 ...
- 剑指offer——04二维数组中的查找
题目: 数组中唯一只出现一次的数字.在一个数组中除一个数字只出现一次之外,其他数字都出现了三次.请找出那个只出现一次的数字. 题解: 如果一个数字出现三次,那么它的二进制表示的每一位(0或者1)也出现 ...
- Django框架(八)—— 模板层:模板导入、模板继承、静态文件
目录 模板导入.继承.静态文件 一.模板导入 1.语法 2.使用 二.模板的继承 1.使用模板的继承 2.强调(注意点) 三.静态文件 1.在配置文件settings中配置过静态文件 2.导入使用静态 ...
- 35-Ubuntu-组管理-01-添加组/删除组/确认组信息
组管理 提示: 创建组/删除组的终端命令都需要sudo执行,标准用户没有权限! 序号 命令 作用 01 sudo groupadd 组名 添加组 02 sudo groupdel 组名 删除组 03 ...
