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;     } ```jsonp+springmvc解决跨域问题

相关文章

SpringMVC1.MVC架构MVC是模型(Model)、视图(View)、控制...
SpringMVC学习笔记1.SpringMVC应用1.1SpringMVC简介​Spring...
11.1数据回显基本用法数据回显就是当用户数据提交失败时,自...
一、SpringMVC简介1、SpringMVC中重要组件DispatcherServlet...
1.它们主要负责的模块Spring主要应用于业务逻辑层。SpringMV...
3.注解开发Springmvc1.使用注解开发要注意开启注解支持,2.注...