在web开发区发过一次,没有理想答案,来这里碰碰运气
我有个对象是public class Topic {
private int tpid;
private String tptitle;
private User user;
private String tpcontent;
private Date tptime;
private Board board;
private int tpreplynum;
private String tpstop;
private String tpico;现在我通过传进来的版块id查到相同的版块帖子列出来 现在想列出作者的名字                       s = HibernateUtil.getSession();
String hql = "from Topic as topic where topic.board.bdid=:n ";
Query query = s.createQuery(hql);
query.setInteger("n", tpboardid);
topiclist = query.list();
                        ActionContext ac = ActionContext.getContext();
                        ac.put("topiclist", topiclist);我想问一下如何在jsp页面用EL表达式把作者姓名读出来高手多多指点啊~~~~~~~~~~~~~~~~~~~~~~~~~~

解决方案 »

  1.   

    private User user有没有加上OneToOne的关联?  并且把fetch lazy="false"
      

  2.   

    首先,你要确定hibernate的配置文件配置了级联查询,可以查出user的值
    然后在页面上这么写:
    <c:forEach items="${topiclist}" var="list">
       ${list.user.name}
    </c:forEach>
      

  3.   

    我的是多对一的关系
    <many-to-one name="user" column="tpuserid"></many-to-one>  是这样写的请问三楼该怎么设置级联查询啊
      

  4.   

    加上cascade="all" not-null="true" lazy="false" class="XXX.User"