开发者

Jetty server allow all cross origins

开发者 https://www.devze.com 2023-03-14 21:35 出处:网络
I use jetty as java lib to run my local se开发者_运维知识库rver, that has static content. How can I configure this server to allow all cross origins?

I use jetty as java lib to run my local se开发者_运维知识库rver, that has static content. How can I configure this server to allow all cross origins? This is the code of my server:

        Server server = new Server(8087);

        Context staticContext = new Context(server, "/", 0);
        staticContext.setHandler(new ResourceHandler());
        staticContext.setResourceBase("./static");
        staticContext.setContextPath("/");
        try {
            server.start();
        } catch (Exception e1) {
            e1.printStackTrace();
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消