javascript - 从弹簧控制器获取数据
问题描述
我需要从 spring 控制器获取数据,但服务器总是返回 403 Forbidden。Spring 服务器使用 LDAP 身份验证。我添加了凭据: 'include',但没有任何改变。
这是我的 download.js
fetch("/test", {
credentials: 'include',
method: "POST",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Cache': 'no-cache'
}
})
.then((response)=>{
alert(response);
return response.json();
})
.then((data)=>{
console.log(data);
alert(data);
});
这是我的控制器
@RestController
public class TestController {
@Autowired
private CalcVersionsService calcVersionsService;
@PostMapping("/test")
@ResponseBody
public Set<CalcVersion> test(){
return calcVersionsService.findAll();
}
}
如何向服务器发出授权请求?
解决方案
推荐阅读
- python - 在 UDF 的 withColumn 之后,运行 count() 给出 TypeError: 'NoneType' object is not subscriptable
- google-cloud-firestore - Firestore:为什么在操场上而不是在应用程序中运行(作为查询)
- conda - 使 conda 用户成为不同的 condarc 配置文件
- c++ - C++ 在 MergeSort 期间测量内存使用情况
- azure-iot-edge - 开发模块时如何获取sasKey或connectionString?
- java - List azure ad using msgraph-sdk-java
- angular - 如何在 Storybook 中为 Angular 启用样式源映射
- php - PHP中的匿名函数内容不起作用
- python - 根据条件删除重复项
- php - PHP 与 CSS 兼容吗?