Angular POST RESTful API для Ejb, приводящий к ошибке 404 not found - PullRequest
0 голосов
/ 07 октября 2019

У меня возникли проблемы при попытке отправить 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

Есть идеи, почему это так? Спасибо!

1 Ответ

0 голосов
/ 07 октября 2019

попробуйте это в угловых.

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

Я всегда отправляю сообщения, как это в угловых. Если это не сработает. Вы должны проверить, есть ли на сервере перехватчик.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...