日期:2014-05-20  浏览次数:20638 次

struts <html:select>标签问题
<%
  Depts dept=new Depts();
  dept.setId(1);
  dept.setName("技术部");
  Depts dept1=new Depts();
  dept1.setId(2);
  dept1.setName("财务部");
  List<Depts> list=new ArrayList<Depts>();
  list.add(dept);
  list.add(dept1);
  request.setAttribute("dept",dept);
  %>
  <html:select property="id"> //为什么老提示这行Cannot find bean under name org.apache.struts.taglib.html.BEAN property属性设置的值不是bean里的属性吗
  <html:option value="0">--请选择--</html:option>
  <html:optionsCollection name="dept" value="id" label="name"/>
  </html:select>

------解决方案--------------------
<html:select></html:select> html前缀的标签是struts专用的,用于后面formBean与JSP页面实现数据双向绑定,当你访问该jsp页面时,先实例化后面formBean,把页面里有html标签的property对应上formBean的属性,完成赋值操作,但是找不到该属性,肯定报错,jsp页面无法正常显示