其中由于sex字段的枚举类型,因此这里将sex根据select得到的option来转换为了枚举中的id对应的值。也就是:
z
1: MALE
2: FAMALE
但在发出请求之后,服务端日志中出现如下的问题:
2020-03-02 22:59:50.722 WARN 10864 --- [nio-8080-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `cn.zyt.springbootlearning.domain.SexEnum` from number 2: index value outside legal index range [0..1]; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `cn.zyt.springbootlearning.domain.SexEnum` from number 2: index value outside legal index range [0..1]
at [Source: (PushbackInputStream); line: 1, column: 40] (through reference chain: cn.zyt.springbootlearning.domain.User["sex"])]