mvc4 filter ajax,Spring MVC filter get custom jquery ajax header

Here's the deal, any help would be greatly appreciated because as of now I am at a loss.

I'm setting custom headers in my jQuery.ajax like so:

$.ajax({

type:'GET',

url: url,

dataType: 'json',

headers: {

'customHeader': 'value',

}, etc...

I'm using spring mvc and spring security with a custom filter and getting the header like this:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,

ServletException {

HttpServletResponse httpResponse = (HttpServletResponse) response;

HttpServletRequest httpRequest = (HttpServletRequest) request;

httpResponse.setHeader("Access-Control-Allow-Origin", "*");

String header = httpRequest.getHeader('customHeader');

Unfortunately the header is always null, I've tried things like using beforeSend in the ajax call still same effect. Can anyone please she some light on this?

Remote Address:127.0.0.1:8080

Request URL:http://localhost:8080/ecom/ws/session

Request Method:OPTIONS

Status Code:401 Unauthorized

Request Headersview parsed

OPTIONS /ecom/ws/session HTTP/1.1

Host: localhost:8080

Connection: keep-alive

Access-Control-Request-Method: GET

Origin: null

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36

Access-Control-Request-Headers: accept, ecom_string_s3c, ecom_client_uuid, content-type

Accept: */*

Accept-Encoding: gzip,deflate,sdch

Accept-Language: en-US,en;q=0.8,es;q=0.6

Response Headersview parsed

HTTP/1.1 401 Unauthorized

Date: Wed, 02 Jul 2014 18:15:03 GMT

Access-Control-Allow-Origin: *

Access-Control-Allow-Headers: ecom_string_s3c, ecom_client_uuid, content-type

Content-Length: 0

Server: Jetty(6.1.26)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值