Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/328.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
从Http6 Httpclient进行post调用时,Java HttpServletRequest参数为空_Java_Spring_Angular_Spring Boot - Fatal编程技术网

从Http6 Httpclient进行post调用时,Java HttpServletRequest参数为空

从Http6 Httpclient进行post调用时,Java HttpServletRequest参数为空,java,spring,angular,spring-boot,Java,Spring,Angular,Spring Boot,我正在尝试将用户名和密码从Angular 6客户端发送到我的Spring boot身份验证服务 身份验证服务正在工作,因为我可以通过“AdvanceRESTClient”chrome扩展点击REST APT,但当我尝试访问身份验证服务时,我的客户端无法发送用户名和密码的请求正文。 这是我的密码: getUserDetails(username, password) { const body = { 'username': username, 'password': password };

我正在尝试将用户名和密码从Angular 6客户端发送到我的Spring boot身份验证服务

身份验证服务正在工作,因为我可以通过“AdvanceRESTClient”chrome扩展点击REST APT,但当我尝试访问身份验证服务时,我的客户端无法发送用户名和密码的请求正文。 这是我的密码:

getUserDetails(username, password) {
const body = {
  'username': username,
  'password': password
};

return this.http.post<TokenParams>('http://localhost:8080/login',
  body,
  {
    headers: {
      'content-type':"application/json",
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'POST',
      'Access-Control-Allow-Headers': 'Origin, Content-Type, Accept, Authorization, X-Request-With',
      'Access-Control-Allow-Credentials': 'true'
    }
  }
);

请让我知道我是否遗漏了什么

对我来说,这听起来像是CORS问题,您是否也尝试过将CORS支持添加到SpringBoot项目中?您可以检查浏览器控制台以查看是否看到任何错误吗?@MarceloTataje Yes CSRF保护已禁用<代码>httpSecurity.csrf().disable().authorizeRequests()
System.out.println("Request Body:\n" + req.getReader().lines() .collect( Collectors.joining( System.lineSeparator())));