0

我是 Spring 新手,我有这个例外。

我有一个 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";
}

这里,实体 Expediente:

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

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

一些帮助?谢谢!

4

1 回答 1

0

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

于 2016-08-26T18:30:16.770 回答