springMVC 使用对象作为入参时,默认是使用request 参数的,此时需要使用 url?params=xx 的请求方式,
这是使用 angular2 的方式为:
let reqHeaders = new Headers({'Content-Type': 'application/x-www-form-urlencoded'});
return this.http
.post(this.heroesUrl, "email=eeee&id=1111", options)
.toPromise()
.then(res => res.json())
.catch(this.handleError);
如果需要使用json方式传递参数,则在springMVC的对象前加上 @RequestBody,
let reqHeaders = new Headers({'Content-Type': 'application/json'});
return this.http
.put(this.heroesUrl, JSON.stringify(jso), options)
.toPromise()
.then(res => res.json())
.catch(this.handleError);
浙公网安备 33010602011771号