0
Performing an ajax request
function buscarDisciplina(){
var codigoDisciplina = String($("#codigo").val());
$.ajax({
url: urlApplication+"/grade-curricular/buscar-disciplina/"+codigoDisciplina,
type: 'GET',
data: codigoDisciplina,
dataType: 'JSON',
success: function(response) {
$("#disciplina").val(response);
}
});
}
Which calls the controller
@PreAuthorize("hasAuthority('PERM_GRADE_CURRICULAR_CADASTRAR')")
@RequestMapping(value = "/buscar-disciplina/{codigoDisciplina}")
public Disciplina bucarDisciplina(@PathVariable String codigoDisciplina) {
return disciplinaService.findByCodigo(codigoDisciplina);
}
Service
public Disciplina findByCodigo(String codigo){
return disciplinaRepository.findByCodigo(codigo);
}
Repository
public Disciplina findByCodigo(String codigo); //uso JpaRepository<Disciplina, Long>
Entity
@Size(max = 10)
@NotEmpty
@Column(name = "codigo")
private String codigo;
However when sending the request
It gives the error of the above image ... I have no idea what it could be ....
urlApplication
that you asked at the url, that’s correct?– Marconi
Yes, it goes on top of the @Requestmapping controller(value = "/seek-discipline/{codeDiscipline}") correctly, but gives this error
– Marcus Daniel
@Proctontesla tries to put the note
@ResponseBody
in his methodbucarDisciplina
, this way he sends a json as an answer, he won’t look for a template that doesn’t exist– Denis Rudnei de Souza