安装配置Tomcat9.0
安装tomcat9.0
设置tomcat用户和密码
选择jre环境
设置安装位置
完成安装
配置Tomcat跨域设置
添加跨域jar包
- cor-filter-2.4.jar
- java-property-utils-1.9.1.jar
这个可以去maven仓库下载相关jar包
将jar包放到tomcat的lib目录下,C:\Program Files\Apache Software Foundation\Tomcat 9.0\lib
修改web.xml文件
文件在conf目录下,C:\Program Files\Apache Software Foundation\Tomcat 9.0\conf
添加如下配置代码
<!-- 提供跨域支持 -->
<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>Accept, Origin, X-Requested-With, Content-Type, Last-Modified</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>
到这Tomcat跨域设置完成