I am trying to make a POST updating an String Array, using jQuery. The server is a boot Spring MVC Server. When I do the POST, the response from the server is HTTP 403 Forbidden
.
Spring Controller
@RequestMapping(value="getlistmap", method = RequestMethod.POST) public @ResponseBody String getListMapfromOneProject(HttpServletResponse response, Principal p,@RequestBody String respostas) throws IOException { System.out.println("A AJAX call has been detected!"); return "ok!"; }
POST code:
var respostas=["hello","hi","bye"]; var urlprova = 'getlistmap'; $.ajax({ type: 'POST', url: urlprova, dataType: 'json', data: JSON.stringify(respostas), success: function (data) { alert("updated successfully"); }, error: function (xhr, ajaxOptions, error) { alert(err.status); alert('Cannot update, ' + err.responseText); }
});
Console from Server (the URL and method Controller seems to be mapped correctly):
2014-11-20 18:44:53.427 INFO 6724 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler] 2014-11-20 18:44:53.466 INFO 6724 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView palmaslab.mapas.controller.myController.login() 2014-11-20 18:44:53.466 INFO 6724 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/getlistmap],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String palmaslab.mapas.controller.myController.getListMapfromOneProject(javax.servlet.http.HttpServletResponse,java.security.Principal,java.lang.String) throws java.io.IOException 2014-11-20 18:44:53.467 INFO 6724 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/addProjectPostoSaude],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView palmaslab.mapas.controller.myController.addProject()