无法从类型[java.lang.String]转换为类型[java.sql.Time]

时间:2016-08-28 11:21:29

标签: java html spring hibernate

无法从输入中获取时间字段,不断收到错误消息:

  

字段'prepTime'上对象'recipe'中的字段错误:被拒绝的值   [04:00];代码   [typeMismatch.recipe.prepTime,typeMismatch.prepTime,typeMismatch.java.sql.Time,typeMismatch];

     

参数[org.springframework.context.support.DefaultMessageSourceResolvable:       代码[recipe.prepTime,prepTime];参数[];默认消息[prepTime]];       默认消息[无法将类型[java.lang.String]的属性值转换为属性所需的类型[java.sql.Time]   '准备时间';       嵌套异常是org.springframework.core.convert.ConversionFailedException:       无法从类型[java.lang.String]转换为类型[@ org.springframework.format.annotation.DateTimeFormat java.sql.Time]   价值'04:00';      嵌套异常是org.springframework.core.convert.ConverterNotFoundException:      没有找到能够从类型[java.util.Date]转换为类型的转换器   [@ org.springframework.format.annotation.DateTimeFormat java.sql.Time]]

我的POJO课程:

DELIMITER //

CREATE PROCEDURE `proc_IF` (IN param1 INT)
BEGIN
    DECLARE variable1 INT;
    SET variable1 = param1 + 1;

    IF variable1 = 0 THEN
        SELECT variable1;
    END IF;

    IF param1 = 0 THEN
        SELECT 'Parameter value = 0';
    ELSE
        SELECT 'Parameter value <> 0';
    END IF;
END //

和输入字段格式为html:

@Entity
public class Recipe {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Lob
    private byte[] photo;

    @Size (min=3, max=100, message = "size of field Name must be between 3 and 100")
    private String name;

    private String description;

    @ManyToOne
    private Category category;

    @DateTimeFormat(pattern = "mm:ss")
    private Time prepTime;

    @DateTimeFormat(pattern = "mm:ss")
    private Time cookTime;

    private String addedFlag;

那么,我做错了什么?

0 个答案:

没有答案