search

Home  >  Q&A  >  body text

java - servlet可以结合CROS实现ajax跨域访问吗?如何做?

如题目中描述

大家讲道理大家讲道理2892 days ago391

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-18 09:19:21

    You don’t need to raise your hand to ask these questions...

    http://www.open-open.com/lib/view/open1463878352785.html

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 09:19:21

    If it is servlet的话,那简简单单一个filter, it can be done, and someone has already done it, just use it: cors-filter.

    If your problem is that you don’t understand cross-domain, then you have to read: Building public APIs and CORS

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 09:19:21

    public class CorsConfigurerAdapter extends WebMvcConfigurerAdapter{
    
      @Override
      public void addCorsMappings(CorsRegistry registry) {
        
        registry.addMapping("/api/*").allowedOrigins("*");
      }
    }

    reply
    0
  • Cancelreply