Convert it to BigDecimal
Vraptor is expecting a comma to decimals because of your server’s Locale (which is probably pt-BR
).
If you make your call like this: http://localhost:8080/app-teste/produto/1234/76,60
it must convert correctly, but I do not recommend you leave so.
What you can do is receive one String
and make the conversion to BigDecimal
normally
@Get("/{produtoDto.codBarras}/{preco}")
public void produtoComPreco(ProdutoDto produtoDto, @PathParam("preco")
String preco) {
System.out.println(new BigDecimal(preco));
}
You can try adjusting Locale but it must be set to pt-BR
, according to your server, and changing to another locale may influence your entire application.
Another solution would be to overwrite the Bigdecimal Converter, if you find it necessary.
Follow a link from a person who has been through this problem: http://www.guj.com.br/t/resolvido-vraptor-3-4-1-problema-com-converter/298683/2
And a link to a related link: https://github.com/caelum/vraptor4/issues/504
Have you tried passing the value with a comma? Maybe it’s some configuration of
Locale
.– Felipe Marinho