Ejb的Angular POST RESTful API,导致404找不到错误

问题描述 投票:0回答:1

尝试将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;
}

但是,我收到此错误消息:

enter image description here

任何想法为什么会这样?谢谢!

java angular spring api ejb
1个回答
0
投票

尝试一下。

export const httpOptions = {
    headers: new HttpHeaders({
        'Content-Type': 'application/json'
    })
};
this.http.post(your-url,your-data, httpOptions);

我总是这样发送帖子。如果不起作用。您应该检查一下,服务器中是否有拦截器。

© www.soinside.com 2019 - 2024. All rights reserved.