尝试将RESTful API从Angular发送到EJB时遇到问题。这是我的component.ts:
this.opUserAdminWinService.retrievePegRoleList().subscribe(resf => {
console.log(resf);
});
和我的service.ts:
serviceAPI = SERVER_API_URL;
mainAPI = '/api/securityactivity/securityactivity';
retrievePegRoleList() {
const url: string = this.serviceAPI + this.mainAPI + '/RetrievePegRoleList';
return this.http.post(url, this.httpOptions);
}
在我的Controller.java中:
@PostMapping("/RetrievePegRoleList")
public Vector RetrievePegRoleList()
throws JaMClientRemoteException, JaMException {
return getSecurityActivity().RetrievePegRoleList();
}
在我的EjbBean类中:
public Vector RetrievePegRoleList() throws JaMClientRemoteException, JaMException;
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public Vector RetrievePegRoleList() throws JaMClientRemoteException, JaMException
{
Vector pegRoleList;
try {
String dataSource = JaM.getProperties().ORD_DATA_SOURCE;
RetrievePegRoleListTask retrievePegRoleListTask = new RetrievePegRoleListTask(dataSource);
retrievePegRoleListTask.execute();
pegRoleList = retrievePegRoleListTask.getResult();
} catch (Exception e) {
throw new JaMClientRemoteException(this.ERR_EXCEPTION_JAM, e.toString());
}
return pegRoleList;
}
但是,我收到此错误消息:
任何想法为什么会这样?谢谢!
最佳答案
试试这个角度。
export const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
this.http.post(your-url,your-data, httpOptions);
我总是这样发送帖子。
如果不起作用。您应该检查一下,服务器中是否有拦截器。