我正在从我的 Angular 8 Liferay 7.3 Portlet 发出一个 POST 请求,并尝试serveResource
在类的方法中获取其内容MVCResourceCommand
。
前端 JS 如下所示:
submit() {
let message = {
type: "form",
body: this.model
};
this.http.post<any>("http://my/url", message).subscribe(response => {
console.log(JSON.stringify(response));
})
}
消息命中端点,因此后端配置良好。基于this,this和this我还设置了"com.liferay.portlet.requires-namespaced-parameters=false"
属性,以便命名空间不会成为问题 - 因此,基本上,检查列表中的每个点都已完成,并且应该可以访问请求正文。到目前为止,我阅读的每篇文章都在谈论使用 获取请求信息ParamUtil.getString(uploadRequest, "text");
,但我不确定如果主体是 JSON 对象,这应该如何工作 - 我的意思是,如果 POST 主体看起来像这样,我应该如何检索该值:
{
"firstVal": "abc",
"secondVal": "def",
"another": {
"objectVal1": 1,
"objectVal2": 2
}
}