我在我的实体中将DiscriminatorValue属性设置为transient,其唯一目的是稍后在我的jsp页面中访问,但jsp无法渲染它抛出 java.lang.IllegalStateException:渲染异常视图,我正在使用瓷砖FYI。提前致谢
@Entity
@DiscriminatorValue("YesNo")
public class Child extends Parent{ // parent entity has inheritance strategy
.....
DiscriminatorValue type; //want to access this variable in spring form
@Transient
public String getDiscriminatorValue(){
type= this.getClass().getAnnotation( DiscriminatorValue.class );
return type == null ? null : type.value();
}
}
//somewhere in jsp i have,
${child.type}
答案 0 :(得分:0)
对您的班级进行以下更改。
@Transient
String type; //want to access this variable in spring form
public String getDiscriminatorValue(){
DiscriminatorValue type = this.getClass().getAnnotation( DiscriminatorValue.class );
return type == null ? null : type.value();
}
或者您可以将您的鉴别器作为只读属性。
在您的父类中添加define DiscriminatorColumn
@DiscriminatorColumn(name = "Dtype", discriminatorType = DiscriminatorType.STRING)
@Column(name = "Dtype", insertable = false, updatable = false)
private String type;
//类型
的getter和setter