About server cross-domain issues (using cors resolution)

Source: Internet
Author: User

1. Configure Cors Dependencies

Pom Added

<Dependency><groupId>Com.thetransactioncompany</groupId><Artifactid>Cors-filter</Artifactid><version>1.7</version></Dependency><Dependency><groupId>Com.thetransactioncompany</groupId><Artifactid>Java-property-utils</Artifactid><version>1.9</version></Dependency>

2. Configure the filter

Add the following configuration to Web. XML: (You must put the filter on top, otherwise it will not work)

<Filter> <Filter-name>CORS</Filter-name> <Filter-class>Com.thetransactioncompany.cors.CORSFilter</Filter-class> <Init-param> <Param-name>Cors.alloworigin</Param-name> <Param-value>*</Param-value> </Init-param><Init-param> <Param-name>Cors.supportedmethods</Param-name> <Param-value>GET, POST, HEAD, PUT, DELETE</Param-value> </Init-param> <Init-param> <Param-name>Cors.supportedheaders</Param-name> <Param-value>*</Param-value> </Init-param> <Init-param> <Param-name>Cors.exposedheaders</Param-name> <Param-value>Set-cookie</Param-value> </Init-param> <Init-param> <Param-name>Cors.supportscredentials</Param-name><Param-value>True</Param-value> </Init-param> </Filter> <filter-mapping> <Filter-name>CORS</Filter-name> <Url-pattern>/*</Url-pattern> </filter-mapping>

Configuration complete, restart, cross-domain problem solved!!

About server cross-domain issues (using cors resolution)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.