When I query data from database via hibernate value isn't correct
I use spring and hibernate in my project everything look fine when insert data into database but when I query and display in jsp the value isn't correct it's look like I print object
Model.User@1c0c66a, Model.User@1228521, Model.User@1526c5f
How to fix this ?? I should encode or I do something wrong when query????
@Override
public List findByUserName() {
List list = getHibernateTemplate().find(
"from User");
return list;
}
This is me开发者_如何学运维thod that I use to query data out
List customerList = userdao.findByUserName();
and this statement I use for get return list
${customerList}
and this is EL that I use in jsp
I don't sure what make value like this I think I must forgot something because it can query but it didn't display correctly.
Thank in advance, Mart
use this jstl code instead:
<c:forEach var="customer" items="${customerList}">
${customer.name} - ${customer.surname} ...
</c:forEach>
its up to you which fields you want to show (I assumed you have the fields name and surname) and how you want to show them.
To be able to use jstl you need to add this include line in the beginning of your jsp page:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
精彩评论