Problems converting object in a Spring Boot project

1

This is my project

WhenIsubmittheformitgivesthiserroronscreen

This is a Spring Boot project, I thought I did not need a class to convert to the category combo, but as I gave the error message I resolve to create the class convert as you can see below;

import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

import br.com.armazem.model.Categoria;

public class CategoriaConverter implements Converter<String, Categoria> {

    @Override
    public Categoria convert(String codigo) {
        if (!StringUtils.isEmpty(codigo)) {
            Categoria categoria = new Categoria();
            categoria.setCodigo(Long.valueOf(codigo));
            return categoria;
        }
        return null;
    }

}

Even though it keeps generating error, what can I do?

I'm new Spring Boot programmer.

    
asked by anonymous 05.06.2017 / 20:42

1 answer

0

I do not understand much more if converting a string to long tries this, category.setCode (Long.parseLong (c));

    
05.06.2017 / 21:04