spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [java.util.Date] 而POST请求,传入时间类型字符串,后台是可以解析成Date类型的. 出现这个错误,在需要接受Date类型的字符串参数的controller层中,加入: @InitBinder public void initBinder(WebDataBinder binder) { S
场景 网站localhost:56338要访问网站localhost:3001的服务 在网站localhost:3001中增加CORS相关Java Config @Configuration @Order(Ordered.HIGHEST_PRECEDENCE) public class CORSConfiguration { @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter()
最近用Spring Boot搭建了一些restful api,写起来真的很爽.但是当用Postman测试一些POST请求的接口的时候却遇到一些问题,上网冲浪查了一堆博客资料,发现都讲得不清不楚,于是记录下来希望也能让同道少走弯路. 假设有一个POST请求的接口是接受一个对象而不是单个参数,如注册接口,需要传递一个LoginUser对象,该对象的结构如下: @Data @AllArgsConstructor @NoArgsConstructor public class LoginUser { p