【发布时间】:2019-08-11 05:42:28
【问题描述】:
我有一个 Angular 页面,用户在其中选择两个 PDF,然后将它们上传到 API。他们在那里被解析并返回比较的 URL。然后返回的 URL 会显示在 iframe 中。
为了调试,我设置了一个静态返回值“https://google.ch”。
为什么当状态码为 200 时会出现错误?
POST方法:
onSubmit() {
console.log('Submitted');
const formModel = this.prepareSave();
this.loading = true;
this.http.post('http://localhost:8080/demo', formModel)
.subscribe(response => {
console.log(response);
const returnValue = JSON.stringify(response);
console.log('parsed: ', returnValue);
this.comparejobdataService.url = response.toString();
this.router.navigate(['/draftable']);
});
setTimeout(() => {
this.loading = false;
}, 10000);
}
春季启动
@PostMapping("/demo")
String pdfDiff(@RequestParam("file1") MultipartFile file1, @RequestParam("file2") MultipartFile file2) {
System.out.println("File 1: " + file1);
System.out.println("File 2: " + file2);
return "https://google.ch";
}
感谢您的任何帮助或建议!
【问题讨论】:
-
JSON.parse: unexpected character- 你期望将"https://google.ch"解析为JSON会得到什么?
标签: angular spring-boot post