小编tce*_*vis的帖子

将序列化的HTML时间字段转换为java.time.LocalTime

我创建了一个带有事件表单对象的Spring Boot Controller。

    @RestController
    @RequestMapping("/Event")
    public class EventController {

        @RequestMapping(value = "/create", method = RequestMethod.POST) 
        private synchronized List<Event> createEvent(Event inEvent) {       
            log.error("create called with event: " + inEvent);
            create(inEvent);
            return listAll();
        }
    }
Run Code Online (Sandbox Code Playgroud)

Event类看起来像这样(省略了getters / setters)

public final class Event {
   private Integer id;
   private Integer periodId;
   private String name;
   @DateTimeFormat(pattern = "dd/MM/yyyy")
   private LocalDate eventDate;
   private LocalTime startTime;
   private LocalTime endTime;
   private Integer maxParticipants;
   private String status;
   private String eventType;  
}
Run Code Online (Sandbox Code Playgroud)

我在startTime和endTime字段上遇到Spring Type不匹配错误

Field error in object 'event' on …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc localtime spring-boot

3
推荐指数
1
解决办法
837
查看次数

标签 统计

java ×1

localtime ×1

spring ×1

spring-boot ×1

spring-mvc ×1