三种解决方法:Cannot deserialize value of type `java.util.Date` from String

一、改前端

加入格式化:  value-format="yyyy-MM-dd HH:mm:ss"

二、改后端实体类

注释掉 @JsonFormat 注解

// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date pastDueTime;

三、新增配置类

这种没试过,能用请评论留言

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;
    }
 
}

     ============== 没有了

你可能感兴趣的:(JavaWeb,Vue,SpringBoot,java,elementui,vue.js)