标签的引入和beandefine的用法

本文介绍了一个使用Struts框架实现的多选框示例,展示了如何通过Java和Struts标签库来构建动态多选表单。该示例包括了颜色选择及水果选项的多选设置,并演示了如何为每个选项指定不同的tabindex值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="
http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib prefix="html"  uri="/WEB-INF/struts-html.tld" %>

<%@ taglib uri="
http://struts.apache.org/tags-logic" prefix="logic" %>



<html:html xhtml="true" lang="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Multibox Example</title>
<html:base />
<link rel="stylesheet" type="text/css" href="../../css/example.css" />
</head>
<body>
<html:link page="/jsp/multibox/source.jsp">
  <img src="../../images/code.gif" width="24" height="24" alt="View Source" class="icon" />
</html:link>
<a href="../../index.jsp"><img src="../../images/return.gif" height="24" width="24" alt="Return to examples page" class="icon" /></a>
<h1>Multibox Example</h1>
<hr noshade="noshade"/>
<html:form action="/processMultibox">
<bean:define id="tabInitId" value="5"></bean:define>

<bean:define id="maxTabIndex" value="0"></bean:define>
 <logic:iterate name="colors" id="color" indexId="indexId">
  <html:multibox property="colors" tabindex="<%=Integer.toString(Integer.valueOf(tabInitId)+8*indexId.intValue()) %>">
   <bean:write name="color" />
  </html:multibox>
  <bean:write name="color" /><br />
  <% maxTabIndex = Integer.toString((indexId+1)*8); %>
  </logic:iterate>
 <hr />
 <p>
 <html:multibox property="fruits" value="Pineapples" tabindex="<%=Integer.toString(Integer.valueOf(maxTabIndex))%>"/>Pineapple<br />
  <html:submit />
  <html:cancel />
  <html:reset />
 </p>
</html:form>

</body>
</html:html> 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值