I have this code, but this doesn't redirect well to the page results.
This is my code html:
<script type="text/javascript">
function cargaDatos2(){
var param1= $('#selector2').val();
var param2= $('#selector3').val();
//Llamada a la funcion que carga los datos en la base de datos.
$.ajax({
type: "POST",
data: {"param1" : param1, "param2" : param2},
url: "http://localhost:8080/prueba",
success: function(data){
alert("Ejecutado correctamente");
},
error: function (data){
alert("Error en la ejecucion");
}
});
}
</script>
And this is my code in Java, Spring:
@RequestMapping(value="/prueba", method=RequestMethod.POST)
public String checkPersonInfo(@RequestParam (required=false) String param1, @RequestParam (required=false) String param2) {
System.out.printf("1-el nombre seleccionado es: %s \n", param1);
System.out.printf("2-el nombre seleccionado es: %s \n", param2);
return "redirect:/results";
}
why doesn't it redirect? this is my output in console browser:
prueba POST 302 Found application/x-www-form-urlencoded jquery.min.js:19
results GET 200 OK text/html http://localhost:8080/prueba Redirect
What is the problem?
Aucun commentaire:
Enregistrer un commentaire