form中定义了一个实体  在action中set实体的值  怎么用<bean:write>将实体中的属性显示到jsp页面中  我用的<bean:write name="entity" property="entName"/>取不出来  求大神指教!!!!

解决方案 »

  1.   

    你在action中,有把这个实体,放入 request 或 session 中么?可以指定你实体存放的域,比如:
      <bean:write name="entity" property="entName" scope="request"/>
    相当于(这里忽略了类型转换):
      <%=request.getAttribute("neeke").getEntName()%>
      

  2.   

    在form中这样定义一个实体
      private BusNonsealdetails entity = new BusNonsealdetails();
      public BusNonsealdetails getEntity()
    {
    return entity;
    }

    public void setEntity(BusNonsealdetails entity)
    {
    this.entity = entity;
    }
    在action中给实体赋值
    public ActionForward goLook(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
            BusNonsealdetailsForm bForm =(BusNonsealdetailsForm)form;
    bForm.setEntity(service.getBusNonsealdetailsById(bForm.getPkId()));
    // BusNonsealdetails bn = service.getBusNonsealdetailsById(bForm.getPkId());
    // request.setAttribute("bn", bn);
    return mapping.findForward("toLook");
    }在jsp页面中怎样把entity中的属性entName取出来??
      

  3.   

    Action中至少要:
      request.setAttribute("entity", bForm.getEntity);
      

  4.   

    那样的话就不需要用form了吧  直接用request.setAttribute("entity", entity);就行了啊
      

  5.   

    formbean作用把页面的值放到formbean中,然后传给action,返回的时候,不使用formbean