Cannot deserialize value of type `java.util.Date` from String
2021-03-06 02:27
阅读:719
今天使用element-ui组件的el-date-picker,提交el-form 到后台,然后时间选项是这样的
后台接收是这样的:
但是提交后提示,我时间格式不对 Cannot deserialize value of type `java.util.Date` from String 。。。
百度后解决办法:
新增一个配置类,返回类型为MappingJackson2HttpMessageConverter的bean
-
-
import java.util.ArrayList;
-
import java.util.List;
-
-
import org.springframework.context.annotation.Bean;
-
import org.springframework.context.annotation.Configuration;
-
import org.springframework.http.MediaType;
-
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-
-
import com.fasterxml.jackson.databind.ObjectMapper;
-
-
@Configuration
-
public class WebConfig {
-
-
@Bean
-
public MappingJackson2HttpMessageConverter getMappingJackson2HttpMessageConverter() {
-
MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
-
//设置日期格式
-
ObjectMapper objectMapper = new ObjectMapper();
-
-
mappingJackson2HttpMessageConverter.setObjectMapper(objectMapper);
-
//设置中文编码格式
-
List
list = new ArrayList (); -
list.add(MediaType.APPLICATION_JSON_UTF8);
-
mappingJackson2HttpMessageConverter.setSupportedMediaTypes(list);
-
return mappingJackson2HttpMessageConverter;
-
}
-
-
}
问题解决
文章来自:搜素材网的编程语言模块,转载请注明文章出处。
文章标题:Cannot deserialize value of type `java.util.Date` from String
文章链接:http://soscw.com/index.php/essay/60656.html
文章标题:Cannot deserialize value of type `java.util.Date` from String
文章链接:http://soscw.com/index.php/essay/60656.html
评论
亲,登录后才可以留言!