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”)
看一看