org.springframework.beans.NotReadablePropertyException:无效的属性' texto' bean类[java.util.ArrayList]:

时间:2014-09-17 14:26:13

标签: java spring jsp spring-mvc

我在JSP页面中有错误。 错误是文本变量具有geters和setter方法,但模型具有这些方法

这是我的模特:

@Entity
public class Comentario implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(columnDefinition="TEXT")    
@Size(min = 5, message = "Mínimo 5 caracteres")
private String texto;

@DateTimeFormat(pattern = "dd/mm/yyyy")
private Date data;

@ManyToOne
@JoinColumn(name = "usuario_id")
@JsonBackReference
private Usuario usuario;

@ManyToOne
@JoinColumn(name = "projeto_id")
@JsonBackReference
private Projeto projeto;

public Comentario() {
    super();
}

public Comentario(Long id, String texto, Date data, Usuario usuario,
        Projeto projeto) {
    super();
    this.id = id;
    this.texto = texto;
    this.data = data;
    this.usuario = usuario;
    this.projeto = projeto;
}

public Long getId() {
    return id;
}

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

public String getTexto() {
    return texto;
}

public void setTexto(String texto) {
    this.texto = texto;
}

public Date getData() {
    return data;
}

public void setData(Date data) {
    this.data = data;
}

public Usuario getUsuario() {
    return usuario;
}

public void setUsuario(Usuario usuario) {
    this.usuario = usuario;
}

public Projeto getProjeto() {
    return projeto;
}

public void setProjeto(Projeto projeto) {
    this.projeto = projeto;
}
}

在我的jsp页面中有代码:

<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Informações do Projeto</title>
<link
href="<c:url value="/webjars/bootstrap/3.1.1/css/bootstrap.min.css" />"
rel="stylesheet" />
<link href="<c:url value="/resources/css/estilo.css" />"
rel="stylesheet" />
</head>

<body onload="verificarSeExisteUlNaPagina()">
<jsp:include page="../modulos/header.jsp" />

<div class="container" style="margin-bottom: 70px;">
            <div>


                <div class="container ">
                    <h3 id="headComentarios">Comentários do Projeto</h3>
                    <ul id="comentarioList" class="ca-menu">
                        <c:forEach var="comentario" items="${projeto.comentarios}">
                            <li class="well">
                                <div class="nome_usuario">${comentario.usuario.nome}</div>
                                <div class="corpo_texto">${comentario.texto}</div>
                                <div class="formatacao_data">
                                    <fmt:formatDate pattern="dd/MM/yyyy hh:mm"
                                        value="${comentario.data}" />
                                </div>
                            </li>
                        </c:forEach>
                    </ul>
                </div>

            </div>

            <div class="row text-center">
                <label for="textocomentarioInput"><h3>Comentários</h3></label>

                    <form:form id="formularioCadastroComentario" role="form" commandName="comentario" method="POST"
                         cssClass="form-horizontal">
                        <form:textarea id="textocomentarioInput" path="texto"
                            placeholder="Comentário"></form:textarea>
                        <div class="error-validation">
                            <form:errors path="texto"></form:errors>
                        </div>

                        <br>

                        <input name="botao" id="botaoEnviarComentario"
                            class="btn btn-primary" value="Enviar" />
                        <a href="<c:url value="/projeto/index"></c:url>"
                            class="btn btn-default">Voltar</a>

                    </form:form>
            </div>
        </div>
    </div>
</div>

<jsp:include page="../modulos/footer.jsp" />


<script
    src="<c:url value="/webjars/jquery-maskedinput/1.3.1/jquery.maskedinput.min.js" />"></script>

</body>
</html>

当我访问该页面时显示错误:

org.springframework.beans.NotReadablePropertyException: Invalid property 'texto' of bean class [java.util.ArrayList]: Bean property 'texto' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

0 个答案:

没有答案