将在wildfy上运行的Maven Web应用程序(在netbeans中开发)转换为HTTP安全

时间:2019-04-15 13:39:23

标签: java maven netbeans https web-applications

因此,我使用maven在Java中创建了一个简单的Web应用程序,然后使用Wildfly对其进行了部署,并使用了javascript应用程序(本地主机)来使用Web服务。现在,JavaScript应用程序正在https服务器中运行,每次我尝试使用Web服务时,都会遇到以下错误。

Mixed Content: The page at 'x.html' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'y'. This request has been blocked; the content must be served over HTTPS.

我试图用Google搜索这个问题,但是没有找到我理解的解决方案。有人说我只需要在wildfly配置文件中找到https端口,然后在我的Web服务中更改端口即可。某个解决方案显示了我需要在解决方案中实现的一堆代码,但随后有人说更改不是在代码中,而是在wildfly的配置文件中。我真的很困惑,任何人都可以向我解释如何解决此问题,或者知道要遵循的好教程。如果有帮助的网络服务示例。

@POST
@Path("insertVolunt")
@Produces(MediaType.APPLICATION_XML)
@Consumes("*/*")
public Response insertVolunt(String voluntario) {
    CreateDatabase DB = new CreateDatabase();
    DB.createDB();
    Queries q = new Queries();
    Insert in = new Insert();
    Gson gson = new Gson();
    RegisterVolunt volunt = gson.fromJson(voluntario, RegisterVolunt.class);
    System.out.println(volunt.toString());
    if (q.getEmailVolunt(volunt.getMail())) {
        return Response.status(1)
                .entity("<erro> none </erro>")
                .header("Access-Control-Allow-Origin", "*")
                .header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT")
                .header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
    }

    if (volunt.getTele().length() != 9 || (volunt.getTele().charAt(0) != 9 && volunt.getTele().charAt(0) != 2)) {
        return Response.status(2)
                .entity("<erro> none </erro>")
                .header("Access-Control-Allow-Origin", "*")
                .header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT")
                .header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
    }

    in.insertVolunt(volunt.getName(), Integer.parseInt(volunt.getTele()), volunt.getDataNasc(), volunt.getMail(), volunt.getPass(), volunt.getExp(), volunt.getName());

    return Response.ok() //200
            .entity("<erro> none </erro>")
            .header("Access-Control-Allow-Origin", "*")
            .header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT")
            .header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();

}

请帮忙。

0 个答案:

没有答案