【发布时间】: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