1
I would like a help, I am new with Spring MVC and I am trying to send a numeral value of an Enum that I own in my class, but I am not succeeding, it is only accepted the Nominal value.
I’d like some help. Thank you
Example:
public enum TipoCliente
{
PessoaFisica,
PessoaJuridica
}
class Clientes
{
@Column(nullable = false)
private TipoCliente tipoCliente;
//getters e setters
}
@RequestMapping(value = "/salvar", method = RequestMethod.POST)
public String salvar(Clientes cliente)
{
clientesDAO.save(cliente);
}
<input type="text" name="tipoCliente" value="0"> <- Não aceita
<input type="text" name="tipoCliente" value="PessoaFisica"> <- Aceita
As for that I understood, but what I would really like to know is if there is no Annotation as in JPA to receive that Enum numeral? Thank you for your attention.
– Joao Alberto
@Enumerated(EnumType.ORDINAL)
 private TipoCliente tipoCliente;
But I recommend using this approach carefully because it will be "stuck" to the enumeration order and other types may appear complicating the maintenance of the code in the future.– Gedson Silva