Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 与spring的集成_Java_Reactjs_Spring Boot_Cookies - Fatal编程技术网

Java 与spring的集成

Java 与spring的集成,java,reactjs,spring-boot,cookies,Java,Reactjs,Spring Boot,Cookies,我有一个网站,后端在春天,前端在春天。我使用 Cookie cookie = new Cookie("userId", testDTO.getId()); userCookie.setPath("/"); response.addCookie(userCookie); 但是当react在控制器上发布请求时,我的浏览器没有得到cookie。firefox中的存储空间是空的 前端代码: const requestOptions = { method: 'POST',

我有一个网站,后端在春天,前端在春天。我使用

Cookie cookie = new Cookie("userId", testDTO.getId());
userCookie.setPath("/");
response.addCookie(userCookie);
但是当react在控制器上发布请求时,我的浏览器没有得到cookie。firefox中的存储空间是空的

前端代码:

const requestOptions = {
            method: 'POST',
            headers: {'Content-Type': 'application/json'},
            body: JSON.stringify({
                name: username,
                stayLogged: false
            })
        };

       fetch('http://localhost:8080/health-check/post',requestOptions)
           .then(response => response.json())
           .then(data =>{console.log(data);})

我修好了。刚刚添加到控制器中的post映射
@交叉原点(原点=”http://localhost:3000,allowCredentials=“true”)

我修复了它。刚刚添加到控制器中的post映射
@交叉原点(原点=”http://localhost:3000,allowCredentials=“true”)

看一看