struts中html:options的问题
我的框架采用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>
有谁知道问题出在什么地方?
具体代码如下:
--------------------------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>
有谁知道问题出在什么地方?
...全文
相关推荐
Ajax+struts用户验证
Ajax+struts实现用户查重验证,包含两种js写法,一种使用原始方法,一种使用ajax一封装的prototype-1.4.0.js<br>
struts2-s标签
那就从简单的标签说起吧!1.x中常用的标签只有4中html、bean、logic、tiles 而struts2.0里的标签却没有分类,只用在jsp头文件加上 就能使用struts2.0的标签库 下面就介绍每个标签的具体应用实例说明:按字母排列
js 原始ajax请求实现 struts2
js ajax请求实现 struts2 action js ajax请求实现 struts2 action js ajax请求实现 struts2 action js ajax请求实现 struts2 action js ajax请求实现 struts2 action
jquery-form 异步提交表单
基于jquery的异步表单提交【jquery-form.js,其中的Demo是基于SSH的,里面有Struts标签。欢迎下载!
struts操作select标签实例
这是一个对struts一个标签(html:select)的操作,主要为了操作下拉列表控制的数据读取,适合于初学者。。


