日期:2014-05-18  浏览次数:20730 次

求助 struts结构 jsp得不到传值
各位大哥帮忙看一下问题在哪

程序目的:jsp中接收Action的赋值。相关代码如下:

1.AreaAction.java中赋值
Collection   coll   =   new   ArrayList();
coll   =   db.select(..);
if   (coll   ==   null   ||   coll.isEmpty())
{return   actionMapping.findForward( "fail ");
}else

{
request.setAttribute( "Area ",   coll);
return   actionMapping.findForward( "success ");
}

2.jsp4.jsp中获取   Area的值
<logic:iterate   id= "area "   name= "Area "   type= "com.cargo1.model.Area "   scope= "request ">
<tr   valign= "top "   bgcolor= "#FFFFFF ">
<td   height= "20 "   align= "center "   bgcolor= "#FFFFFF "> <bean:write   name= "area "   property= "name "   filter= "true "/> </td>
<td   height= "20 "   align= "center "   bgcolor= "#FFFFFF "> <bean:write   name= "area "   property= "resume "   filter= "true "/> </td>
</tr>
</logic:iterate>

3.struts-config.xml配置action-mapping

<action-mappings   type= "org.apache.struts.action.ActionMapping ">
<action   path= "/areaAction "   type= "com.cargo1.control.AreaAction "   validate= "false "   scope= "request ">
<forward   name= "success "   path= "/jsp4.jsp "   redirect= "true "   />
</action>

<action   path= "/areaAction "   type= "com.cargo1.control.AreaAction "   validate= "false ">
<forward   name= "fail "   path= "/jsp1.jsp "   redirect= "true "   />
</action>
</action-mappings>

问题:运行jsp4.jsp时从request中找不到Area,错误提示如下:
javax.servlet.ServletException:   Cannot   find   bean   Area   in   scope   null”

那位大哥帮帮忙给小弟解释一下,万分感谢

------解决方案--------------------
request.setAttribute( "Area ", coll);

<logic:iterate id= "area " name= "Area " >
<tr valign= "top " bgcolor= "#FFFFFF ">
<td height= "20 " align= "center " bgcolor= "#FFFFFF "> <bean:write name= "area " property= "name " filter= "true "/> </td>
<td height= "20 " align= "center " bgcolor= "#FFFFFF "> <bean:write name= "area " property= "resume " filter= "true "/> </td>
</tr>
</logic:iterate>


<action path= "/areaAction " type= "com.cargo1.control.AreaAction " validate= "false " scope= "request ">
<forward name= "success " path= "/jsp4.jsp " />
</action>

<action path= "/areaAction " type= "com.cargo1.control.AreaAction " validate= "false ">
<forward name= "fail " path= "/jsp1.jsp " />
</action>
------解决方案--------------------
Collection coll = new ArrayLi