Tomcat a requests data in Tomcat B (I am different on the same machine with 2 Tomcat ports, time is measured on different machines)
The blogger uses AJAX requests for data in a request B, using the following method to
In the requested Tomcat B application, add the following code to Web. XML:
Add the following jar to the Tomcat B application:
Cors-filter-1.7.jar; Java-property-utils-1.9.jar
<!--Tomcat cross-domain request start-up <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.supported Methods</param-name> <param-value>get, POST, HEAD, PUT, delete</param-value> </init -param> <init-param> <param-name>cors.supportedHeaders</param-name> < Param-value>accept, Origin, X-requested-with, Content-type, last-modified</param-value> </init-param> ; <init-param> <param-name>cors.exposedHeaders</param-name> <param-value>set-c ookie</param-value> </init-param> <init-param> <PARAM-NAME>CORS.SUPPORTSC Redentials</param-name> <param-value>true</param-value> </init-param> </filter> <!--request Filter Start-up <filter-mapping> <filter-name>CORS</filter-name> <url-pattern>/*</url-pattern>
<!--for security reasons, you can write the requested path in the filter--</filter-mapping> </filter-mapping> <!--The request filter ends--& lt;! --Tomcat cross-domain request ended--
For security reasons, the requested path can be written in the filter
Multiple filter notation:
<filter-mapping> <filter-name>CORS</filter-name> <url-pattern>/xxx</ url-pattern> </filter-mapping> <filter-mapping> <filter-name>cors</ filter-name> <url-pattern>/XXX</url-pattern> </filter-mapping> < filter-mapping> <filter-name>CORS</filter-name> <url-pattern>/xxx</ url-pattern> </filter-mapping> <filter-mapping> <filter-name>cors</ filter-name> <url-pattern>/XXX</url-pattern> </filter-mapping>
Code reference: http://www.cnblogs.com/chiyouguli/p/4283349.html
PS: This article for Bo Master original, reprint please indicate source: http://www.cnblogs.com/Y-zhiwei/.
Tomcat cross-domain request