【问题标题】:Web service Rest using Angular2 and spring with Enum TypesWeb 服务 Rest 使用 Angular2 和带有枚举类型的 spring
【发布时间】:2016-08-04 09:48:16
【问题描述】:

我想用 JSON 格式播种一个对象,该对象具有枚举类型的属性 当我启动我的请求时,我发现错误 403

这是我在前台的服务

export enum DocumentComponentType {
    DIV_12,
    DIV_4_4_4,
    DIV_4_8,
    DIV_8_4,
    DIV_6_6,
}
export interface DocumentComponent {
    id: number;
    type: DocumentComponentType;
    // documentContents: DocumentContent[];
}

 this.gridService.addDocumentComponent({id: 0, type: DocumentComponentType.DIV_8_4}, 6)
                    .subscribe(data => {
                            this.documentComponent = data;
                        },
                        error => alert('Erreur ' + error),
                        () => {
                            console.log("finished  ");
                        }
                    );

在服务器端

这是我的课

public class DocumentComponent {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    DocumentComponentType  type;
    @OneToMany(mappedBy = "documentComponent")
    private List<DocumentContent> documentContents;
    @ManyToOne
    Document document;
    DocumentComponent(){

    }
}

还有我的枚举

public enum  DocumentComponentType {
    DIV_12,
    DIV_4_4_4,
    DIV_4_8,
    DIV_8_4,
    DIV_6_6,
}

我收到错误 500(内部服务器错误)

【问题讨论】:

  • 查看服务器日志文件。在那里你应该看到异常的根本原因
  • 这是我在服务器 NULL 中的错误违反了“id”列的 NOT NULL 约束但我已经生成了Value

标签: spring typescript enums


【解决方案1】:

我收到错误 500(内部服务器错误)

这意味着服务器上存在错误。您发布的代码是客户端代码。

修复

查看服务器端日志(和或)将调试器附加到服务器以查看那里发生了什么。

更多

https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_Error 该错误是一个通用错误消息,本质上意味着发生了意外情况

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-24
    • 2020-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多