no data when run my webapp
Hi,
I'm trying to create a HotelBooking application in SpringMVC.
I create a database in MySQL named: dbHotels with a table: tblhotels with a few columns (name,address,...)
In Eclipse I create a Config.java, HotelController.java, HotelDAO.java, HotelDAOcoll.java and a Hotel.java for my modelling
In my Home.jsp I want to list all the hotels, For this moment I have one record in my table (tblhotels)
When I try to run the webapp I see nothing ...
This is my code for my Home.jsp, I dont know what to write in my value, I'm not sure its hotel.name
Code:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1 style="color:red">Welcome on hotels.com!</h1>
<p>test</p>
<c:out value="${hotel.name}"/>
</body>
</html>
In my HotelDAOColl i have this code
Code:
package eu.hotel.dao;
import eu.hotel.example.model.Hotel;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
@Repository
public class HotelDAOcoll implements HotelDAO{
@PersistenceContext
private EntityManager entityManager;
@SuppressWarnings("unchecked")
public List<Hotel> findAll(){
Query query = entityManager.createQuery("select h.name from Hotel h");
return query.getResultList();
}
}
Thnx!