ajax cors jar,CORS Filter

Installation

The CORS Filter can run in any

Java Servlet 3.0+

compatible web container, such as the popular open source

Apache Tomcat

server. Installation is a straightforward 3-step process.

Download the

cors-filter-.jar file and its

java-property-utils-.jar dependency,

and put them into the CLASSPATH

of your web server.

If you have Apache Tomcat there are two CLASSPATH

choices: If you intend to use CORS with a single web application

put the JAR file in

$CATALINA_HOME/webapps//WEB-INF/lib/

To make CORS available globally, to all web applications, place the JAR in

$CATALINA_HOME/lib/

Alternatively, if you use Maven to build your project WAR file,

add the following dependency to your pom.xml

com.thetransactioncompany

cors-filter

[ version ]

Open the WEB-INF/web.xml file of the web application where you

intend to enable CORS and add a CORS Filter

declaration

and mapping.

The XML declaration to load the CORS filter:

CORS

com.thetransactioncompany.cors.CORSFilter

To use a variant of the CORS Filter that can automatically detect

changes to the configuration file and reconfigure itself use

the following declaration instead:

CORS

com.thetransactioncompany.cors.autoreconf.AutoReconfigurableCORSFilter

Then declare a filter mapping to tell the web server which

servlets or URLs should be cross-domain-request enabled.

Example of applying the CORS filter to a single servlet:

CORS

MyServlet

And how to apply the CORS filter to all web app URLs:

CORS

/*

Have a look at the web.xml

of the demo CORS application included with the download package to see

a complete CORS filter declaration and mapping example.

Finally, remember to restart your web server for the installation to take effect.

Important note:

By default the CORS Filter will apply a "public access" CORS policy, allowing

all cross-site requests through (including credentials/cookies). Leaving

the CORS Filter at this setting would actually be fine for most situations

as CORS is not about adding server security; its primary intent is to protect the

browser - the legitimate JavaScript apps running in it and the user's confidential data,

such as cookies.

If you want to modify the default CORS Filter behaviour, proceed to

the configuration instructions.

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值