そのため、Angular からスプリング ブート バックエンドに画像とテキストを x-wwww-form-urlencoded の方法で送信しようとしています。アンギュラーサービスメソッドは次のとおりです。
img(tags:HTMLInputElement, des:HTMLInputElement, selectFile){
let url = "http://localhost:8080/api/v1/add_item"
const body = new HttpParams()
body.set("img", selectFile)
body.set("tags", tags.value)
body.set("des", des.value)
return this.http.post<Isecurity[]>(url, body.toString(),{
headers:new HttpHeaders()
.set('Content-Type', 'application/x-www-form-urlencoded')
} )
}
そして残りの側で:
@PostMapping("add_item")
@CrossOrigin
public Map<String, Boolean> add_item(@RequestParam MultipartFile img, @RequestParam String tags, @RequestParam String des){
Map<String, Boolean> values = new HashMap<>();
values.put("response", true);
return values;}
@RequestParam タグのせいで、私が受け取る唯一の応答は 500 サーバーエラーです...