我在Angular2应用程序和数据源之间建立连接,并进行弹簧分离。
看起来像是
{{Angular2App< => SpringApp< => DataSourceApp}}
我可以使用任何api来实现此功能吗?
Angular app与数据源应用程序隔离。
使用FormData上传文件的角色帖子:
let form = new FormData();
form.append('filedata', filedata);
this.http.post('/rest/upload' + this.nodeId), form).map(response => response.json());
如何接收在角应用中发布的FormData并通过restTemplate请求将其传递给dataSource?
@RequestMapping(value = "/rest/upload", method = { RequestMethod.POST })
public ResponseEntity<String> upload(@PathVariable("nodeId") final String nodeId) {
return this.restTemplate.exchange(dataUploadUrl + nodeId, HttpMethod.POST, String.class);
}
答案 0 :(得分:1)
我认为你应该使用@RequestBody
,如何:
@RequestMapping(value = "/rest/upload", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<String> upload(@Valid @RequestBody final String nodeId){
//your code here
}