Spring-MVC 跨域 CrossOrigin 注解 通过注解设置跨域 demo 如下 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 package com.huifer.source.controller; import org.springframework.web.bind.annotation.*; import java.util.HashMap; @CrossOrigin(maxAge = 3600) @RequestMapping("/") @RestController public class JSONController { @ResponseBody @GetMapping(value = "/json") public Object ob() { HashMap<String, String> hashMap = new HashMap<>(); hashMap.put("1", "a"); return hashMap; } } 切入点: org.springframework.web.servlet.handler.AbstractHandlerMethodMapping#registerHandlerMethod org.springframework.web.servlet.handler.AbstractHandlerMethodMapp……
阅读全文