67,549
社区成员




public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
DynaActionForm daf = (DynaActionForm)form;
List<LabelValueBean> li = new ArrayList<LabelValueBean>();
LabelValueBean lvb1 = new LabelValueBean("xu","小学");
LabelValueBean lvb2 = new LabelValueBean("cz","初中");
LabelValueBean lvb3 = new LabelValueBean("gz","高中");
LabelValueBean lvb4 = new LabelValueBean("du","大学");
li.add(lvb1);
li.add(lvb2);
li.add(lvb3);
li.add(lvb4);
daf.set("mlist", li);
//request.setAttribute("mlist", li);
return new ActionForward("/select.jsp");
}
<form-bean name="indexForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="mlist" type="java.util.ArrayList"></form-property>
<form-property name="val" type="java.lang.String"></form-property>
</form-bean>
<action-mappings>
<action path="/demo" type="com.ccb.dsl.struts.DemoAction" name="indexForm" scope="request"/>
</action-mappings>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<html:form action="/demo">
<html:select property="por">
<html:option value="">请选择</html:option>
<html:options collection="mlist" property="label" labelProperty="value"/>
</html:select>
</html:form>
</body>
</html>