可以考虑使用cors-filterCORS Filter is a universal solution for fitting Cross-Origin Resource Sharing (CORS) support to Java web applications. CORS is a recent W3C effort to introduce a standard mechanism for enabling cross-domain requests in web browsers and participating servers.具体实现可以参考CORS 跨域 实现思路及相关解决方案,里面详细说了CORS和JSONP实现的对比,以及web.xml中CORS的具体配置