【问题标题】:java.lang.IllegalStateException: Exception occurred rendering viewjava.lang.IllegalStateException:渲染视图发生异常
【发布时间】:2017-03-26 03:28:13
【问题描述】:

我的实体中有属性 DiscriminatorValue 作为瞬态,其唯一目的是稍后在我的 jsp 页面中访问,但 jsp 无法呈现它抛出 java.lang.IllegalStateException: 出现异常呈现视图,我正在使用瓷砖仅供参考。在此先感谢

@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}

【问题讨论】:

  • 这个值是多少?请向我们提供足够的信息来解决问题。
  • 对不起,我的错,应该改成类型(现在编辑)
  • 我试图复制您的问题我在线程“main”org.hibernate.MappingException 中收到以下异常异常:无法确定类型:javax.persistence.DiscriminatorValue,
  • 这就是为什么我一直保持这种短暂性:)

标签: hibernate spring-mvc


【解决方案1】:

对您的班级进行以下更改。

@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();
    }

或者您可以将您的鉴别器设置为只读属性。

在你的父类中添加定义 DiscriminatorColumn

@DiscriminatorColumn(name = "Dtype", discriminatorType = DiscriminatorType.STRING)

 @Column(name = "Dtype", insertable = false, updatable = false)
    private String type;

//类型的getter和setter

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-16
    • 2013-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-30
    • 2016-06-25
    相关资源
    最近更新 更多