Java CorsConfiguration
时间: 2023-10-18 22:26:15 浏览: 81
Java CorsConfiguration 是用于配置 Spring Boot 应用程序的跨域访问的类。它可以通过设置不同的属性来定义允许跨域请求的来源、方法和头部等信息。在上述代码中,CorsConfiguration 的实例被创建,并设置了以下属性:
- `setAllowCredentials(true)`:允许请求带有验证信息
- `addAllowedOrigin("*")`:允许访问的客户端域名
- `addAllowedHeader("*")`:允许服务端访问的客户端请求头
- `addAllowedMethod("*")`:允许访问的方法名,包括 GET、POST 等
这些属性可以根据实际需求进行修改和配置,以实现自定义的跨域访问策略。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [Java 之 CORS跨域问题](https://blog.csdn.net/u013919153/article/details/124098263)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [JAVA 服务器端配置跨域请求配置类](https://blog.csdn.net/m0_59757074/article/details/129749093)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文