首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

!struts传值有关问题

2012-02-23 
求助!!!!!!struts传值问题各位大哥帮忙看一下问题在哪程序目的:jsp中接收Action的赋值。相关代码如下:1.Are

求助!!!!!!struts传值问题
各位大哥帮忙看一下问题在哪

程序目的: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 "   >
<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   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>

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

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


[解决办法]


request.getSession().setAttribute( "Area ", coll);

热点排行