Tenho este REST
@RequestMapping(value = "/buscaEnderecoCep/{cep}", method = RequestMethod.GET, produces = { "application/json" })
public ResponseEntity<ViewEnderecoCepDTO> buscaEnderecoCep(@PathVariable String cep) {
try {
return new ResponseEntity<ViewEnderecoCepDTO>(viewEnderecoCepServico.buscaEnderecoCep(cep), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getMessage());
}
return null;
}
Quando chamo pela URL pelo navegador assim: http://localhost:8080/nota-fiscal_servico/buscaEnderecoCep/30860100, funciona, trocando no metodo java, de POST para GET.
No Javascript
$("input.cep").blur(function() {buscarCep();});
function buscarCep() {
$.ajax({
type : "POST",
url : "buscaEnderecoCep",
contentType : "application/json; charset=utf-8",
dataType : "json",
async : true,
data : '{cep:"' + document.getElementById("cep").value + '"}',
success : function(data) {
alert(data.d);
}
});
}
Como deu erro 404, ele não mostra o resultado.
O que pode ser ?