Note that there are some explanatory texts on larger screens.

plurals
  1. POErrors in my springs MVC
    primarykey
    data
    text
    <p>I have written a simple web app in springs but I am facing an error in running the project.The error I am facing is</p> <pre><code>org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/view/UserDetails.jsp at line 22 19: &lt;c:out value="${chat.username}:"/&gt; 20: &lt;c:out value="${chat.message}"/&gt; 21: &lt;/c:forEach&gt; 22: &lt;form:input path="message"/&gt; 23: &lt;input type="submit" value="Send" /&gt; 24: &lt;/form:form&gt; 25: &lt;br&gt; </code></pre> <p>and </p> <pre><code> org.springframework.beans.NotReadablePropertyException: Invalid property 'message' of bean class [java.util.ArrayList]: Bean property 'message' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? </code></pre> <p>My POJO class is</p> <pre><code>package com.beingjavaguys.domain; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.Generated; @Entity @Table(name="messages") public class Chat { @Id @GeneratedValue @Column(name = "user_id") private int id; @Column(name="username") private String username; @Column(name="message") private String message; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } } </code></pre> <p>and my <code>Dispatcher servlet</code> is</p> <pre><code> &lt;bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /&gt; &lt;property name="prefix" value="/WEB-INF/view/" /&gt; &lt;property name="suffix" value=".jsp" /&gt; &lt;/bean&gt; &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName" value="${database.driver}" /&gt; &lt;property name="url" value="${database.url}" /&gt; &lt;property name="username" value="${database.user}" /&gt; &lt;property name="password" value="${database.password}" /&gt; &lt;/bean&gt; &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="annotatedClasses"&gt; &lt;list&gt; &lt;value&gt;com.beingjavaguys.domain.User&lt;/value&gt; &lt;value&gt;com.beingjavaguys.domain.Chat&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="hibernateProperties"&gt; &lt;props&gt; &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt; &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt; &lt;property name="sessionFactory" ref="sessionFactory" /&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>My JSP page is*<em>Now I have edited the page</em>*</p> <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt; &lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt; &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;Group chat | User Details&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;center&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;div style="color: teal;font-size: 30px"&gt;Group Chat&lt;/div&gt; &lt;br&gt;&lt;br&gt; &lt;c:url var="userRegistration" value="saveChat.html"/&gt; &lt;form:form id="chatMessages" modelAttribute="chat" method="post" action="${userRegistration}"&gt; &lt;c:forEach items="${chat}" var="chat"&gt; &lt;c:out value="${chat.username}:"/&gt; &lt;c:out value="${chat.message}"/&gt; &lt;/c:forEach&gt; &lt;form:input path="message"/&gt; &lt;input type="submit" value="Send" /&gt; &lt;/form:form&gt; &lt;br&gt; &lt;/center&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>My Controller is</p> <pre><code>@RequestMapping("/saveChat") public ModelAndView saveChat(@ModelAttribute("chat") Chat chat,BindingResult result){ userService.addChat(chat); return new ModelAndView("redirect:/userList"); } @RequestMapping("/userList") public ModelAndView getUserList() { Map&lt;String, Object&gt; model = new HashMap&lt;String, Object&gt;(); model.put("chat", userService.getChat()); return new ModelAndView("UserDetails", model); } </code></pre> <p>I am unable to grasp the problem here(<strong>Edited the error</strong>).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload