`
lige239141
  • 浏览: 171967 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

struts1中select,radio的解决方法

    博客分类:
  • ssh
阅读更多

 

 

(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;
		}
	}
 

 

 

分享到:
评论

相关推荐

    struts1.x html标签 radio,checkbox,multibox,select的使用

    html:radio,html:checkbox,html:multibox,html:select 与actionform结合使用数组或集合,有多种实现方式

    struts2(checkbox_radio_select)表单标签的应用及详细事例

    要在JSP中使用Struts 2.0标志,先要指明标志的引入。通过在JSP的代码的顶部加入以下代码可以做到这点。 &lt;%@taglib prefix="s" uri="/struts-tags" %&gt;

    配置Struts 2开发环境,了解和熟悉Struts 2的开发流程、了解和熟悉Struts2标签的使用方法.rar

    5.掌握常用标签textfield、radio、paaaword、checkboxlist、select、data的使用方法,实现页面与Action的交互操作 6.要求在创建过程中,包的名称要体现班级和学号,项目名称不需要按照实验手册中书写。在做的过程中...

    struts1标签库

    struts标签库 文章目录 bean:cookie 2 bean:define 3 bean:header 4 bean:include 5 bean:message 5 bean:page 7 bean:parameter 7 bean:resource 8 bean:size 8 bean:struts 9 bean:write 9 html:base 10 ...

    Struts2标签库

    &lt;%@ taglib uri="/struts-tags" prefix="s" %&gt; 结合例子,重点掌握以下标签的用法 (1) (2) (3) &lt;s:if&gt; 、、 (4) (5) (6) 、 (7) 、、、 (8) &lt;s:select&gt;、&lt;s:radio&gt;、&lt;s:checkboxlist&gt;

    深入浅出Struts2(附源码)

    作者处处从实战出发,在丰富的示例中直观地探讨了许多实用的技术,如数据类型转换、文件上传和下载、提高Struts 2应用的安全性、调试与性能分析、FreeMarker、Velocity、Ajax,等等。跟随作者一道深入Struts 2,聆听...

    Struts 2 Form Tags

    In this tutorial we'll explore some of the other Struts 2 form controls. In our previous ... This tutorial will explore using the Struts 2 select, radio, checkbox, and checkboxlist form controls.

    struts2 标签库 帮助文档

    1. &lt;s:bean name=""&gt;&lt;/s:bean&gt;-----类似于struts1.x中的,JavaBean的值 C: 1. &lt;s:checkbox&gt;&lt;/s:checkbox&gt;-----复选框 2. &lt;s:checkboxlist list=""&gt;&lt;/s:checkboxlist&gt;-----多选框 3. &lt;s:combobox list=""&gt;&lt;/s:...

    深入浅出Struts 2 .pdf(原书扫描版) part 1

    书中介绍了如何利用Struts 2 来解决Web 应用开发中的常见问题,同时还深入浅出地探讨了许多能帮助程序员编写Struts 2 应用程序的技巧,如管理页面导航活动、输入验证、国际化和本地化、对Ajax 的支持,等等。书中...

    Struts2标签库的所有

    &lt;%@ taglib uri="/struts-tags" prefix="s" %&gt; 结合例子,重点掌握以下标签的用法 (1) (2) (3) &lt;s:if&gt; 、、 (4) (5) (6) 、 (7) 、、、 (8) &lt;s:select&gt;、&lt;s:radio&gt;、&lt;s:checkboxlist&gt;

    Struts2+API+标签全解+网页说明

    actionerror标签:输出Action中getActionErrors()方法返回的异常信息。 actionmessage标签:输出Action中getActionErrors()方法返回的信息。 component标签:生成一个自定义的组件。 div标签:AJAX标签,生成一个...

    JSP_struts2标签大全

    JSP_struts2标签大全 1.a 3 2.action 3 3. actionerror 4 4. actionmessage 5 5. append 5 6. bean 7 7.checkbox 7 8.checkboxlist 8 9. combobox 9 10. conponent 9 11. date 11 12. datetimepicker 12 13. debug ...

    低清版 大型门户网站是这样炼成的.pdf

    2.2.1 web.xml中struts 2的配置实现 54 2.2.2 struts 2属性配置文件struts.properties详解 55 2.2.3 struts 2核心配置文件struts.xml详解 57 2.3 struts 2应用开发实务 61 2.3.1 struts 2应用开发环境的搭建 62 ...

    Java学习笔记-个人整理的

    \contentsline {chapter}{Contents}{2}{section*.1} {1}Java基础}{17}{chapter.1} {1.1}基本语法}{17}{section.1.1} {1.2}数字表达方式}{17}{section.1.2} {1.3}补码}{19}{section.1.3} {1.3.1}总结}{23}{...

    Spring中文帮助文档

    9.9. 常见问题的解决方法 9.9.1. 对一个特定的 DataSource 使用了错误的事务管理器 9.10. 更多的资源 10. DAO支持 10.1. 简介 10.2. 一致的异常层次 10.3. 一致的DAO支持抽象类 11. 使用JDBC进行数据访问 ...

    Spring API

    9.9. 常见问题的解决方法 9.9.1. 对一个特定的 DataSource 使用了错误的事务管理器 9.10. 更多的资源 10. DAO支持 10.1. 简介 10.2. 一致的异常层次 10.3. 一致的DAO支持抽象类 11. 使用JDBC进行数据访问 ...

Global site tag (gtag.js) - Google Analytics