CORS跨域解决

web.xml


<filter>
        
        <filter-name>CORSfilter-name>
        <filter-class>com.thetransactioncompany.cors.CORSFilterfilter-class>

        
        <init-param>
            <param-name>cors.allowGenericHttpRequestsparam-name>
            <param-value>trueparam-value>
        init-param>

        <init-param>
            <param-name>cors.allowOriginparam-name>
            <param-value>*param-value>
        init-param>

        <init-param>
            <param-name>cors.allowSubdomainsparam-name>
            <param-value>falseparam-value>
        init-param>

        <init-param>
            <param-name>cors.supportedMethodsparam-name>
            <param-value>GET, HEAD, POST, OPTIONSparam-value>
        init-param>

        <init-param>
            <param-name>cors.supportedHeadersparam-name>
            <param-value>Accept, Origin, X-Requested-With, Content-Type, Last-Modifiedparam-value>
        init-param>

        <init-param>
            <param-name>cors.exposedHeadersparam-name>
            
            <param-value>X-Test-1, X-Test-2param-value>
        init-param>

        <init-param>
            <param-name>cors.supportsCredentialsparam-name>
            <param-value>trueparam-value>
        init-param>

        <init-param>
            <param-name>cors.maxAgeparam-name>
            <param-value>3600param-value>
        init-param>

    filter>

    <filter-mapping>
        
        <filter-name>CORSfilter-name>
        <url-pattern>/*url-pattern>
    filter-mapping>

还有两个包,下载地址http://download.csdn.net/download/sunhuwh/10214037

你可能感兴趣的:(#,java,#,HTTP)