Problems converting object to a Spring Boot project

Asked

Viewed 102 times

1

This is my project inserir a descrição da imagem aqui

When I submit the form it gives this error on screen inserir a descrição da imagem aqui

If it is a Spring Boot project, I thought it did not need a class convert to category combo, but as gave the error message I decided to create the convert class 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 he keeps making mistakes, I wonder what I can do?

I am new Spring Boot programmer.

1 answer

0

I don’t understand much more if you’re going to convert a string into a long one, category.setCodigo(Long.parseLong(c));

  • sorry @Aderbal but your suggestion doesn’t help much, I think my problem is more a matter of setting up Spring Boot than the conversion itself.

  • I’m trying to submit a combo in a form in a Spring Boot project

Browser other questions tagged

You are not signed in. Login or sign up in order to post.