微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jsonp+springmvc解决跨域问题

<table class="text"><tr class="li1">
<td class="ln"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

aram(value = "callback",required = false) String callback,                                           HttpServletResponse response) throws CustomException {         long t0 = System.currentTimeMillis();         searchType = StringUtils.trim(searchType);         searchContent = StringUtils.trim(searchContent);           if (StringUtils.isBlank(searchType) || StringUtils.isBlank(searchContent)) {             throw new CustomException("搜索条件为空");         }           log.debug("Request param [searchType]:{},[searchContent]: {} ",searchType,searchContent);           ResponseResult responseResult = new ResponseResult();         switch (searchType) {             case "身份证号":                 responseResult = graphService.selectByCertNo4Smart(searchContent);                 break;             case "姓名":                 responseResult = graphService.selectByName4Smart(searchContent);                 break; //            case "客户类型": //                graph = graphService.selectByCustType4Smart(Profile.CustType.matchDescToCode(searchContent)); //                break;             case "手机号":                 responseResult = graphService.selectByPhone4Smart(searchContent);                 break;             default:    //剩下都是根据边查找     计算出md5 然后根据 vid查找 //                String vid = MD5Utils.md5(searchType + searchContent);                 responseResult = graphService.selectByEdge4Smart(searchType,searchContent);         }           Graph graph = (Graph) responseResult.getData();         //为下文日志打印服务         if (graph == null) {             graph = new Graph(null,null);         }         log.info("Number of node: " + (graph.getNodes() == null ? 0 : graph.getNodes().size()));         log.info("Number of edge: " + (graph.getEdges() == null ? 0 : graph.getEdges().size()));           long t1 = System.currentTimeMillis();         log.info("Request processing time: " + (t1 - t0) + "ms");           //构造MappingJacksonValue,SpringMVC配合jsonp解决浏览器跨域访问问题         MappingJacksonValue mjv = new MappingJacksonValue(responseResult);         mjv.setJsonpFunction(callback);             return mjv;     } ```

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐