1
I am trying to upload an application configured with Spring and is showing error 405.
Controller:
@Controller
@RequestMapping(value = "/solicitacaoDeMaterial")
public class SolicitacaoMaterialController {
@Autowired
private SolicitacaoService solicitacaoService;
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<?> get() {
return new ResponseEntity<>("Solicitacão incluída com sucesso", HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<?> salvar(@RequestBody SolicitacaoVO solicitacao) {
try {
solicitacaoService.salvar(solicitacao);
return new ResponseEntity<>("Solicitacão incluída com sucesso", HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<String>("Ocorreu um erro " + e.getMessage(), HttpStatus.OK);
}
}
Mapeamento da página:
$scope.salvarDados = function () {
$scope.solicitacao.produtos = $scope.produtos;
$http({
method : "POST",
url : "solicitacaoDeMaterial",
data: $scope.solicitacao
}).then(function myChessus(response) {
console.log(response)
}, function myError(response) {
console.log(response)
});
};
Obs: I’ve already added the base href="/formularios/"
at the head of the page.