I'm using Spring 3.2.2 and jQuery.
Everything works fine in local. I made a CORS filter which also works fine.
Every service methods called from another host are working except one. Actually, this is the only method which use @RequestBody
and $.toJSON
/ contentType
at client side.
Spring side :
@RequestMapping(value = "/requestOrder", method = RequestMethod.POST)
@ResponseBody
public Object requestOrder(@RequestBody OrderViewModel order) throws NamingException {
...
}
jQuery side :
$.ajax({
type : 'POST',
url : serviceUrl + 'requestOrder',
crossDomain : true,
data : $.toJSON({ ...orderdata... }),
contentType : 'application/json; charset=UTF-8'
});
Chrome's console log :
XMLHttpRequest cannot load https://REMOTE_HOST/project/service/requestOrder. The request was redirected to 'https://REMOTE_HOST/project/;jsessionid=84781b083f5305ffa22a0adae0a6', which is disallowed for cross-origin requests that require preflight.
HTTP headers :
Request URL:https://.../requestOrder
Request Method:OPTIONS
Status Code:302 Moved Temporarily
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Access-Control-Request-Headers:accept, content-type
Access-Control-Request-Method:POST
Cache-Control:no-cache
Connection:keep-alive
Host:...
Origin:http://...
Pragma:no-cache
Referer:http://...
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102 Safari/537.36
I don't see Content-Type
which should be set... Request method is OPTIONS
?!
This let me think that the issue is coming from Spring but this is actually working in local...
I would be pleased to get some help.