samedi 21 février 2015

JSP Spring Hibernate not showing the ${} list

I have issue with listing my database output, following code does not print the list of names(it seems like contactList is empty):



<%@taglib uri="http://ift.tt/18bwTB1" prefix="spring"%>
<%@taglib uri="http://ift.tt/IED0jK" prefix="form"%>
<%@taglib uri="http://ift.tt/QfKAz6" prefix="c"%>

<!--- a lot of code blahblah

--->

<div class="row">

<table class="table table-hover">

<tr>
<th>Name</th>
<th>Email</th>
<th>Telephone</th>
<th>###</th>
</tr>



<c:if test="${!empty contactList}">

<c:forEach var="contact" items="${contactList}" >
<tr>
<td>${contact.lastname}, ${contact.firstname} </td>
<td>${contact.email}</td>
<td>${contact.telephone}</td>
<td><a href="delete/${contact.id}">delete</a></td>
</tr>
</c:forEach>

</c:if>

</table>
</div>


Controller:



@RequestMapping(value={"/","/index"}, method = RequestMethod.GET)


public String listContacts(Map<String, Object> model) {
List<Contact> list = contactService.listContact();

for ( Contact contact : (List<Contact>) list ) {
System.out.println( "Contact (" + contact.getFirstname() + ") : " + contact.getTelephone() );
}

model.put("contactList", list);
model.put("contact", new Contact());



return "contact";
}


it is worth noting, that the list is not empty inside the controller, as it outputs those:



Contact (tomku) : 420
Contact (dud) : 560
Contact () : 11
Contact (mac) : 22
Contact () : 3232


pom.xml



<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/HBk9RF">
<modelVersion>4.0.0</modelVersion>
<groupId>com.programcreek</groupId>
<artifactId>HelloWorld</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>HelloWorld Maven Webapp</name>
<url>http://ift.tt/19pvvEY;


<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.1.4.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
</dependency>



<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>

<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1102-jdbc41</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>



<!-- SPRING DEPENDENCIES -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>


<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>


</dependencies>

<build>
<finalName>HelloWorld</finalName>
</build>
</project>


what could cause the issue?


Aucun commentaire:

Enregistrer un commentaire