Tomcat service configures all requests across domains – common

Two steps, make Tomcat service configuration all requests across domains, you can be happy to put a variety of static resources, full stack development learning is a lot more convenient. A lot of resources are not easy to find, this time found, directly share with you.

Tomcat, whether local or server, can be configured to fully release all cross-domain requests.

1. Prepare the REQUIRED JAR package


Add the tomcat folder to the lib folder

  • 1) Cers-filter-2.4. jar or 2.5
    1. Java – property – utils – 1.9.1. Jar

CSDN platform resources acquisition method:

Platform integral friends here to get: – integral access to non-integral friends like and attention to get: – like and attention to get to speak code De Oh!

It will look like this when added:

2. Add the configuration to web. XML


Add the following codes under the WebApp node:

    <filter>
		<filter-name>CORS</filter-name>
		<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>CORS</filter-name>
		<servlet-name>/ *</servlet-name>
	</filter-mapping>
	<filter-mapping>
		<filter-name>CORS</filter-name>
		<url-pattern>/ *</url-pattern>
	</filter-mapping>
Copy the code

The screenshot is as follows:

At this point, you’re done. Just a gentle reboot.

Ps: All subsequent requests of this scheme are open to cross domain by default

conclusion

This article mainly covers how to configure Tomcat service to solve cross-domain problems. If you are interested in learning more, you can refer to my original CSDN blog on other platforms. In line with the original intention of sharing, files can be downloaded without points. Hope this article is useful to you, and can skillfully use in the project development.

For easy reading and download, this article has been uploaded to CSDN blog. If there is any error, please correct it in the comment area. If it is helpful, please like and follow it.