java - Angular POST RESTful API 到 Ejb 导致 404 未找到错误

标签 java angular spring api ejb

我在尝试将 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

有什么想法为什么会这样吗?谢谢!

最佳答案

尝试一下 Angular 。

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

我总是以 Angular 发送这样的帖子。 如果不起作用。你应该检查一下Server中是否有拦截器。

关于java - Angular POST RESTful API 到 Ejb 导致 404 未找到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58262794/

相关文章:

java - ThreadPoolScheduler间隔小于任务的执行时间

java - 推荐模板引擎,减少动态内容冗余(Spring Boot)

javascript - Angular 2 应用程序转移到服务层后逻辑无法正常工作

spring - 如何修复 spring batch 中没有正在进行的事务

html - 如何使用 png`s 作为 ionic 选项卡中的图标而不是 svg/现有的 ionic svg`s?

javascript - 当用户在 Angular 6 中键入时更改输入字段文本

java - 存储库未扩展 JpaRepository

java - 选择成员变量条件为真的所有bean

java - 使用 Stream API 填充 Collection

java - Java8 中 Lambda 表达式的内部编译器错误