求救,struts里logic:iterate的问题!

05-03-19 aone0808

action里面的部分:

public ActionForward perform(ActionMapping mapping,ActionForm form,

HttpServletRequest request,HttpServletResponse response)

throws IOException,ServletException

{

Connection con=null;

try

{

con=pool.getConnection();

AttractionDAO attrationDAO=new AttractionDAO(con);

Collection col=attrationDAO.findAll();

request.setAttribute("attractionList",col);//在这儿

return mapping.findForward("success");

}

catch(SQLException e)

{

e.printStackTrace();

throw new RuntimeException("Unable to get connection.");

}

finally

{

try

{

if(con!=null)

{

con.close();

}

}

catch(SQLException e)

{

throw new RuntimeException(e.getMessage());

}

}

}

页面调用的部分

<logic:iterate id="attraction"

name="attractionList"

scope="request"

type="com.wrox.tourism.entity.Attraction">

<tr>

<td><bean:write name="attraction" property="name"/></td>

<td><bean:write name="attraction" property="description"/></td>

</tr>

</logic:iterate>

就这样没有结果输出(我的)

我在页面加上try{}catch{}后

在后台打印出 can't find bean attraction in scope null

为什么会是scope null呢??????????、

aone0808
2005-03-19 10:05

action里面的部分:

public ActionForward perform(ActionMapping mapping,ActionForm form,

HttpServletRequest request,HttpServletResponse response)

throws IOException,ServletException

{

Connection con=null;

try

{

con=pool.getConnection();

AttractionDAO attrationDAO=new AttractionDAO(con);

Collection col=attrationDAO.findAll();

request.setAttribute("attractionList",col);//在这儿

return mapping.findForward("success");

}

catch(SQLException e)

{

e.printStackTrace();

throw new RuntimeException("Unable to get connection.");

}

finally

{

try

{

if(con!=null)

{

con.close();

}

}

catch(SQLException e)

{

throw new RuntimeException(e.getMessage());

}

}

}

页面调用的部分

<logic:iterate id="attraction"

name="attractionList"

scope="request"

type="com.wrox.tourism.entity.Attraction">

<tr>

<td><bean:write name="attraction" property="name"/></td>

<td><bean:write name="attraction" property="description"/></td>

</tr>

</logic:iterate>

就这样没有结果输出(我的)

我在页面加上try{}catch{}后

在后台打印出 can't find bean attraction in scope null

为什么会是scope null呢??????????、

banq
2005-03-19 16:47

指定id=attraction