gpt4 book ai didi

java - HTTP 状态 500 - javax.el.PropertyNotFoundException

转载 作者:行者123 更新时间:2023-11-29 05:14:10 25 4
gpt4 key购买 nike

我正在尝试做简单的 CRUD。我收到此错误 - javax.el.PropertyNotFoundException:在 com.kaasbetrayer.entity.User 类型上找不到属性“isAdmin”。并且不知道如何修复它。

package com.kaasbetrayer.entity;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Type;
import org.hibernate.type.descriptor.sql.TinyIntTypeDescriptor;
@Entity
@Table(name = "user")
public class User implements Serializable{

private static final long serialVersionUID = -6254657371433674903L;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;

@Column
private String name;

@Column
private int age;

@Column
@Type(type = "org.hibernate.type.NumericBooleanType")
private boolean isAdmin;

@Column
private Timestamp createdDate;

public User(){
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public boolean isAdmin() {
return isAdmin;
}

public void setAdmin(boolean isAdmin) {
this.isAdmin = isAdmin;
}

public Timestamp getCreatedDate() {
return createdDate;
}

public void setCreatedDate(Timestamp createdDate) {
this.createdDate = createdDate;
}

@Override
public String toString() {
return "User {id=" + id +
", name=" + name +
", age=" + age +
", isAdmin=" + isAdmin +
", createdDate="+ createdDate + "}";
}
}

堆栈跟踪:

org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: Property 'isAdmin' not found on type com.kaasbetrayer.entity.User
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:555)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

根本原因

javax.el.PropertyNotFoundException: Property 'isAdmin' not found on type com.kaasbetrayer.entity.User
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:268)
javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:221)
javax.el.BeanELResolver.property(BeanELResolver.java:355)
javax.el.BeanELResolver.getValue(BeanELResolver.java:95)
org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110)
org.apache.el.parser.AstValue.getValue(AstValue.java:169)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:943)
org.apache.jsp.WEB_002dINF.pages.userList_jsp._jspx_meth_c_005fout_005f3(userList_jsp.java:400)
org.apache.jsp.WEB_002dINF.pages.userList_jsp._jspx_meth_c_005fforEach_005f0(userList_jsp.java:299)
org.apache.jsp.WEB_002dINF.pages.userList_jsp._jspx_meth_c_005fif_005f1(userList_jsp.java:249)
org.apache.jsp.WEB_002dINF.pages.userList_jsp._jspService(userList_jsp.java:155)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

SQL:

 create table User (
id bigint not null auto_increment,
name varchar(255),
age integer,
isAdmin boolean,
createdDate timestamp,
primary key (id)
)

最佳答案

如果您坚持将属性命名为 isAdmin,那么 get/setter 应该命名为 boolean isIsAdmin()setIsAdmin(boolean isAdmin) .

关于java - HTTP 状态 500 - javax.el.PropertyNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35459738/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com