struts中html:options的问题

zyme007 2007-03-07 02:19:12
我的框架采用strtus+spring,在用html:options时出现 Cannot find bean under name custList 错误
具体代码如下:
--------------------------left.jsp--------------------------
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html>
<body>
<html:form action="/left">
客户名称: <html:select property="customer">
<html:options collection="custList" property="CustId"
labelProperty="CustName" />
</html:select>
</html:form>
</body>
</html>

--------------------------leftForm--------------------------
public class LeftForm extends ActionForm
{
private String customer;
private String custList;

public String getCustomer()
{
return customer;
}

public void setCustomer(String customer)
{
this.customer = customer;
}

public String getCustList()
{
return custList;
}

public void setCustList(String custList)
{
this.custList = custList;
}
}


--------------------------leftAction--------------------------
public class LeftAction extends Action
{
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
{
LeftForm leftForm = (LeftForm) form;
Vector rs = new Vector(2);
rs.add(new LabelValueBean("CSDN", "001"));
rs.add(new LabelValueBean("百度", "002"));

request.setAttribute("custList", rs);
return (new ActionForward(mapping.getInput()));
}
}

--------------------------struts-config.xml--------------------------
<form-beans>
<form-bean name="leftForm" type="com.test.struts.form.LeftForm" />
</form-beans>

<action-mappings>
<action attribute="leftForm" input="/left.jsp" name="leftForm"
path="/left" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy" />
</action-mappings>

<message-resources parameter="com.test.struts.ApplicationResources" />

<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml" />
</plug-in>

--------------------------applicationContext.xml-------------------------
<bean name="/left" class="com.test.struts.action.LeftAction"></bean>



有谁知道问题出在什么地方?

...全文
394 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
傻根她弟 2007-03-09
  • 打赏
  • 举报
回复
...

I Fule U
zyme007 2007-03-09
  • 打赏
  • 举报
回复
我明白问题出在什么地方了。。。我是从http://localhost:9080/left.jsp访问页面,这时custList不存在,所以报错。改为从http://localhost:9080/left.do访问就行了。。。。
zyme007 2007-03-09
  • 打赏
  • 举报
回复
这里是有错误,我用的是LabelValueBean,把代码改为
<html:options collection="custList" property="value"
labelProperty="label" />
但还是报同样的错误
傻根她弟 2007-03-09
  • 打赏
  • 举报
回复
<html:options collection="custList" property="CustId"
labelProperty="CustName" />
问题是不是出在这里啊?

custId custName 在哪里?
zyme007 2007-03-09
  • 打赏
  • 举报
回复
我把leftForm中custList的类型改为ArrayList,还是报一样的错误
kingobject 2007-03-08
  • 打赏
  • 举报
回复
我也记不清楚了
kingobject 2007-03-08
  • 打赏
  • 举报
回复
custList

应该是Object类型把
hjx520 2007-03-08
  • 打赏
  • 举报
回复
<html:options collection="custList
页面接受可是集合类型阿
hjx520 2007-03-08
  • 打赏
  • 举报
回复
private String custList; String 型吗?
不是List或Vector 类型?
zyme007 2007-03-08
  • 打赏
  • 举报
回复
这问题困扰我好几天了。。。哪位能帮我解决了再送300分!
xwchena 2007-03-08
  • 打赏
  • 举报
回复
幫你頂
zyme007 2007-03-07
  • 打赏
  • 举报
回复
自己再顶
zyme007 2007-03-07
  • 打赏
  • 举报
回复
急啊。。。。高手呢。。。
zyme007 2007-03-07
  • 打赏
  • 举报
回复
custList大小写没问题啊
liang8305 2007-03-07
  • 打赏
  • 举报
回复
custList大小写

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧