java http 401_401 API请求状态错误
當(dāng)我試圖實(shí)現(xiàn)只顯示一條消息的簡單web服務(wù)時(shí),總是會遇到這個(gè)錯(cuò)誤(angular5+springboot)
狀態(tài):401,狀態(tài)文本:“確定”,網(wǎng)址:80/本地主機(jī):你好“;,確定:
錯(cuò)誤,}錯(cuò)誤:“。。。標(biāo)題:HttpHeaders
{normalizedNames:Map(0),lazyUpdate:null,lazyInit:}消息:
錯(cuò)誤狀態(tài):“http401”狀態(tài)確定“文本:
"80/本地主機(jī):你好";
控制器.java:
@GetMapping("/hello")
public String sayhello(){ return "{\"message\": \"Hello, world!\"}";}
}
你好.component.ts:
import { Component, OnInit } from '@angular/core';
import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs/Rx';
import { Adresse } from '../shared/adresse';
@Component({
selector: 'app-forgot', templateUrl: './forgot.component.html',
styleUrls: ['./forgot.component.css']
})
export class ForgotComponent implements OnInit {
message: string;
ip: string = Adresse.ip;
constructor(private http: HttpClient) { }
ngOnInit(): void {
this.http.get(this.ip + '/hello').subscribe(data => {
console.log('DATA', data);
this.message = data['message'];
})
}
}
總結(jié)
以上是生活随笔為你收集整理的java http 401_401 API请求状态错误的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java http 401_java
- 下一篇: java.io.FileNotFound