Dubbox Rest 解决跨域问题
来源:互联网 发布:ios内购 元数据丢失 编辑:程序博客网 时间:2024/06/15 15:32
DubboxRest跨域问题解决
a、ajax请求参数中,json格式需要标准格式,手动拼接引号
var data = "{\"title\":\""+title+ "\",\"context\":\""+context+ "\",\"actionType\":"+actionType+ ",\"notifyType\":"+notifyType+ ",\"sendType\":"+sendType+ ",\"startTime\":\""+startTime+ "\",\"endTime\":\""+endTime+ "\",\"activeStartTime\":\""+activeStime+ "\",\"activeEndTime\":\""+activeEtime+ "\",\"weeks\":["+weeks+ "],\"time\":\""+time+ "\",\"fromType\":0}";
public class ControllFilter implements ContainerResponseFilter { public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException { if (containerRequestContext.getMethod().equals("OPTIONS")) { containerResponseContext.getHeaders().add("Access-Control-Allow-Origin", "*"); containerResponseContext.getHeaders().add("Access-Control-Allow-Headers", "Content-Type,x-requested-with,Authorization,Access-Control-Allow-Origin"); containerResponseContext.getHeaders().add("Access-Control-Allow-Methods", "POST, GET, OPTIONS"); containerResponseContext.getHeaders().add("Access-Control-Max-Age" ,"360"); } }}
c、代码方法中给Response添加跨域代码
if (RpcContext.getContext().getResponse(HttpServletResponse.class) != null) { RpcContext.getContext().getResponse(HttpServletResponse.class).addHeader("Access-Control-Allow-Origin","*");}
0 0
- Dubbox Rest 解决跨域问题
- spring rest cors解决跨域问题
- dubboX提供rest服务
- dubbox+rest详细介绍
- dubbox rest学习
- 解决Ajax调用REST跨域的问题
- dubbox开发rest+json指南
- dubbox开发rest+json指南
- dubbox rest调用过程分析
- dubbox为dubbo提供REST服务(dubbox + springmvc)
- REST跨域访问解决CorsFilter
- dubbox 发布rest服务调用过程记录
- ArcGIS_关于rest乱码问题的解决
- 解决dubbox-demo-provider.xml报错的问题:提示Failed to read schema document
- dubbox
- Dubbox
- Dubbox
- dubbox
- 自学之路
- java传值
- [Leetcode] Search in Rotated Sorted Array II
- 2016——关于工作,关于生活
- 关于Corel Vstudio8(会声会影x8)打开出现service pack 3的弹出框
- Dubbox Rest 解决跨域问题
- mxgraph进阶(四)mxGraph再启程
- 学习C 的第五天
- java方法重载原理,案例说明
- UVA-11552-Fewest Flops(DP 序列划分)
- 牛客 · 错题集锦 (三)
- bzoj 3676: [Apio2014]回文串 (回文自动机)
- java并发编程之线程同步辅助类(二)
- inline 内联函数