struts 1におけるselect,radioの解決方法

2656 ワード


 
(1) struts1 select 
1  
	<html:select styleId="categoryName" name="productForm" property="productcategory.id" value="${categoryId}" >
		<logic:iterate id="p" name="productForm" property="productcategoryList">
			<html:option value="${p.id}"><bean:write name="p" property="name"/></html:option>
		</logic:iterate>
	</html:select>
			  	
2 html:optionsCollection
	productcategoryList ActionForm , html:optionsCollection
	<html:select styleId="categoryName" name="productForm" property="productcategory.id">
		<html:optionsCollection  name="productForm" property="productcategoryList" label="name" value="id" />
	</html:select>
			  
3 html:options
	productcategoryList request , html:options
	<html:select styleId="categoryName" name="productForm" property="productcategory.id">
		<html:options collection="productcategoryList" labelProperty="name" property="id"/>
	</html:select>
			  	
 (2)struts1 ,${categoryId} request .
	 <html:select styleId="categoryName" name="productForm" property="productcategory.id" value="${categoryId}" >
		<html:optionsCollection  name="productForm" property="productcategoryList" label="name" value="id" />
	 </html:select>
			  
(3)struts1 radio 
	<html:radio value="0" property="product.issale" name="productForm"> </html:radio>  
        <html:radio value="1" property="product.issale" name="productForm"> </html:radio> 
         XXForm issale set get , value 0 。
        public class XXForm {
	        public void reset(ActionMapping mapping, HttpServletRequest request) {
			super.reset(mapping, request);
			product = new CProducts();
			product.setIssale("0");
		
	       }
	        public String getIssale() {
			return issale;
		}
	
		public void setIssale(String issale) {
			this.issale = issale;
		}
	}