【发布时间】:2017-07-28 15:11:13
【问题描述】:
我实际上找到了解决方案,但我认为有更简单的方法。我正在尝试使用 angular2 发布 json 数据并尝试在 spring 控制器中读取它。
类是
export class EmovieCat{
id:String = "test";
rev:String;
dataModelVersion:number = 99;
}
角度 2 中的邮政编码
this.emv = new EmovieCat();
this._http.post(this._url,JSON.stringify(this.emv)).subscribe(response =>{
console.log(response.json());
});
我得到这样的 json 字符串。
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(this.req.getInputStream()));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String json = "";
if(br != null){
try {
json = br.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
这样我可以得到 json 字符串。 在此先感谢
【问题讨论】: