Bean 类的无效属性 Bean 属性不可读或具有无效的 getter 方法

  • 本文关键字:Bean 属性 无效 方法 getter spring jsp
  • 更新时间 :
  • 英文 :


我是春天的新手,我有这个例外。

我有一个jsp,有很多选择。它们都工作正常,但有一个显示此异常:

org.apache.jasper.JasperException: Ha sucedido una excepción al procesar la página JSP /WEB-INF/pages/nuevo-expediente.jsp en línea 45
42:                     <td>
43:                         <form:select path="expedientePadre.codExpediente">
44:                             <form:option value="-" label="Seleccione un     expediente"/>
45:                             <form:options items="${expedientes}"    itemLabel="codExpediente" itemValue="codExpediente"/>
46:                         </form:select>
47:                         <form:errors path="expedientePadre" element="span"/>
48:                     </td>
org.springframework.beans.NotReadablePropertyException: Invalid property 'codExpediente' of bean class [com.atlantis.atecliente.model.TipoExpediente]: Bean property 'codExpediente' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

我以与其他人相同的方式实现 selct 工作正常。这里是 jsp 代码:

            <tr>
                <td>Expediente padre:</td>
                <td>
                    <form:select path="expedientePadre.codExpediente">
                        <form:option value="-" label="Seleccione un expediente"/>
                        <form:options items="${expedientes}" itemLabel="codExpediente" itemValue="codExpediente"/>
                    </form:select>
                    <form:errors path="expedientePadre" element="span"/>
                </td>
            </tr>   

这里的控制器:

@RequestMapping(value = "nuevo-expediente")
public String createExpedienteGet(Model model) {
    model.addAttribute("expediente", new Expediente());
    model.addAttribute("expedienteP", new Expediente());
    List<TipoResolucion> resoluciones = service.getResoluciones();
    List<TipoExpediente> listaTipos = service.getTipos();
    List<EstadoExpediente> listaEstados = service.getEstados();
    List<Expediente> listaExpedientes = service.getExpedientes();
    List<TipoRelacion> listaRelaciones = service.getRelaciones();
    List<CanalExpediente> listaCanales = service.getCanales();
    List<IdiomaExpediente> listaIdiomas = service.getIdiomas();
    model.addAttribute("resoluciones", resoluciones);
    model.addAttribute("tipos", listaTipos);
    model.addAttribute("estados", listaEstados);
    model.addAttribute("expedientes", listaExpedientes);
    model.addAttribute("tiposRelacion", listaRelaciones);
    model.addAttribute("canales", listaCanales);
    model.addAttribute("idiomas", listaIdiomas);
    return "nuevo-expediente";
}
@RequestMapping(value = "nuevo-expediente", method = RequestMethod.POST)
public String createExpedientePost(@ModelAttribute("expediente") Expediente expediente, BindingResult result) {
    service.createExpediente(expediente);
    return "redirect:expedientes";
}

在这里,实体权宜之计:

@Entity
@Table(name="Expediente")
public class Expediente implements Serializable {
@Id
@Column(length = 15)
private String codExpediente;
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "tipoExpediente")
private TipoExpediente tipoExpediente;
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "estadoExpediente")
private EstadoExpediente estadoExpediente;
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "expedientePadre")
private Expediente expedientePadre;
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "tipoRelacion")
private TipoRelacion tipoRelacion;
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "canalEntrada")
private CanalExpediente canalEntrada;
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "idiomaEntrada")
private IdiomaExpediente idiomaEntrada;
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "idiomaSalida")
private IdiomaExpediente idiomaSalida;
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "tipoResolucion")
private TipoResolucion tipoResolucion;
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name = "canalSalida")
private CanalExpediente canalSalida;
@Column(length = 10)
private String numeroSerie;
@Column(length = 10)
private String numeroHoja;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date fechaRedaccion;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date fechaRecepcion;
@Column(length = 200)
private String asunto;
@Column (length = 1000)
private String descripcion;
@Column(length = 20)
private String usuarioRegistro;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date fechaRegistro;
@Column (length = 20)
private String usuarioModificacion;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date fechaModificacion;
@Column (length = 20)
private String usuarioCierre;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date fechaCierre;
public String getCodExpediente() {
    return codExpediente;
}
public void setCodExpediente(String codExpediente) {
    this.codExpediente = codExpediente;
}
............................
............................

最后是 TipoExpediente 实体

package com.atlantis.atecliente.model;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@Table
public class TipoExpediente implements Serializable {
@Id
@Column(length = 40)
private String tipo;
public String getTipo() {
    return tipo;
}
public void setTipo(String tipo) {
    this.tipo = tipo;
}
}

我认为这可能会发生,因为权宜之计 Padre 属性是同一实体权宜之计的外键,但我不知道解决它......

一些帮助?谢谢!

我认为问题是您的类 TipExpediente 类没有用于属性 codExpedientent 的 getter 或 setter 方法。Spring正在查看您的TipoExpediente类,并期望它具有您在JSP中概述的属性。

相关内容

最新更新