Cannot find bean under name myList

casesky 2004-10-10 02:35:58
jsp

<html:select size="1" property="dc_parent_id" >
<html:options name="myList"/>
</html:select>

form:

/**
* 分类
*/
private Integer dc_parent_id;

action:

SelDocDBS seldoc = new SelDocDBS();
List myList = seldoc.root();
httpServletRequest.setAttribute("myList",myList);

error:

Cannot find bean under name myList


...全文
489 14 打赏 收藏 举报
写回复
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
hanml 2004-12-10
  • 打赏
  • 举报
回复
httpServletRequest.setAttribute("myList",myList);
httpServletResponse.sendRedirect("/docc_add.jsp");
是这样吗?还是那个错!

不要用sendRedirect,用forward(),前者是重新发送一个request,那么你前面放在request里面的mylist已经不存在了,jsp里面肯定找不到了,其他同意 lcz022(阿五)。
popufig 2004-12-07
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3457/3457597.xml?temp=.6715357
123xxx 2004-12-07
  • 打赏
  • 举报
回复
嗯,好像必须用labelValueBean吧,不用的我没试出来过
lcz022 2004-12-07
  • 打赏
  • 举报
回复
<td><html:select name='user' property='right' disabled='true'>
<html:options collection="levelList" property="value" labelProperty="label" />
</html:select></td>

ArrayList arryList= new ArrayList();
arryList.add(new LabelValueBean("1111","1"));
arryList.add(new LabelValueBean("2222","2"));
request.setAttribute("levelList",arryList);

collection="levelList" 的名字和setAttribute("levelList"中的levelList的值一样就可以的。
casesky 2004-10-10
  • 打赏
  • 举报
回复
action:

httpServletRequest.setAttribute("myList",myList);
httpServletResponse.sendRedirect("/docc_add.jsp");
是这样吗?还是那个错!
eamoi 2004-10-10
  • 打赏
  • 举报
回复
有把myList类放到scope里面嘛,比如request/session/pageContext/application?通常这一步在action中完成,比如先request.setAttribute("myList",your bean instance),然后在返回ActionForward对象或者直接转向到jsp页面.
上面出现的问题应该是在scope域里面找不到你要显示的名为myList的bean.
casesky 2004-10-10
  • 打赏
  • 举报
回复
action:

SelDocDBS seldoc = new SelDocDBS();
List myList = seldoc.root();
httpServletRequest.setAttribute("myList",myList);

需要从action中读出数据生成一个List,在select中显示出来。
这么做到地哪出错了?
csqok 2004-10-10
  • 打赏
  • 举报
回复
import org.apache.struts.util.LabelValueBean;


casesky 2004-10-10
  • 打赏
  • 举报
回复
看不懂啊。LabelValueBean是什么?

csqok 2004-10-10
  • 打赏
  • 举报
回复
<td><html:select name='user' property='right' disabled='true'>
<html:options collection="levelList" property="value" labelProperty="label" />
</html:select></td>

import java.util.List;

ArrayList arryList= new ArrayList();
arryList.add(new LabelValueBean("1111","1"));
arryList.add(new LabelValueBean("2222","2"));
List levelList=arryList;
request.setAttribute("levelList",levelList);
casesky 2004-10-10
  • 打赏
  • 举报
回复
<html:options collection="myList" />
同样的错
casesky 2004-10-10
  • 打赏
  • 举报
回复
score?
加到哪里?
csqok 2004-10-10
  • 打赏
  • 举报
回复

<html:options collection="myList" />
ipv 2004-10-10
  • 打赏
  • 举报
回复
找不到阿
加上score="request"试试看呢?
发帖
Java

4.9w+

社区成员

Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
帖子事件
创建了帖子
2004-10-10 02:35
社区公告
暂无公告