`
ddbird
  • 浏览: 32294 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

Indexed property in struts

阅读更多

The simplest demonstration of using indexed properties in Struts can be shown with the following simple bean and JSP page:

package org.apache.struts.webapp.exercise;
import org.apache.struts.action.ActionForm;
public class StringBean extends ActionForm {
private String strAry[] = { "String 0", "String 1", "String 2", "String 3", "String 4" };

public String getStringIndexed(int index) {
return strAry[index];
}

public void setStringIndexed(int index, String value) {
strAry[index] = value;
}
}

First note the two methods in the StringBean class, "getStringIndexed()" and "setStringIndexed()". Note that the "get" method takes an "int" and the "set" method takes an "int" and "String". The Beanutils package and Struts recognizes this arrangement of signatures as an "indexed property", in this case with the property name "stringIndexed".

<!-- indexedtest.jsp -->
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<jsp:useBean id="bean" class="org.apache.struts.webapp.exercise.StringBean"/>
<bean:write name="bean" property="stringIndexed[1]"/>

Note the property value of "stringIndexed[1]". This is intended to reference the indexed property "stringIndexed", and the 1st (zero-based) entry of whatever array or collection which the indexed property represents.

As you might be able to guess, when this page is executed, it will print just the string "String 1", which is the corresponding array entry at that index value.

This is a simple demonstration of what indexed properties can provide.

分享到:
评论
2 楼 ddbird 2007-03-23  
第一种编辑方式有bug
1 楼 ddbird 2007-03-23  


The simplest demonstration of using indexed properties in Struts can be shown with the following simple bean and JSP page:
package org.apache.struts.webapp.exercise;
import org.apache.struts.action.ActionForm;
public class StringBean extends ActionForm {
    private String strAry[] = { "String 0", "String 1", "String 2", "String 3", "String 4" };

    public String getStringIndexed(int index) { 
        return strAry[index]; 
    }
    
    public void setStringIndexed(int index, String value) { 
        strAry[index] = value; 
    }
}

First note the two methods in the StringBean class, "getStringIndexed()" and "setStringIndexed()". Note that the "get" method takes an "int" and the "set" method takes an "int" and "String". The Beanutils package and Struts recognizes this arrangement of signatures as an "indexed property", in this case with the property name "stringIndexed".
<!-- indexedtest.jsp -->
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<jsp:useBean id="bean" class="org.apache.struts.webapp.exercise.StringBean"/>
<bean:write name="bean" property="stringIndexed[1]"/>

Note the property value of "stringIndexed[1]". This is intended to reference the indexed property "stringIndexed", and the 1st (zero-based) entry of whatever array or collection which the indexed property represents.

As you might be able to guess, when this page is executed, it will print just the string "String 1", which is the corresponding array entry at that index value.

This is a simple demonstration of what indexed properties can provide.

相关推荐

    StrutsCatalogLazyList

    在Struts框架中处理bean集合时,通过正确配置Struts标签库中的`indexed`属性、使用嵌套标签以及采用适当的延时加载策略,可以有效地解决“索引超出范围”的问题,并确保应用程序的稳定性和性能。

    BeanUtils详细解说

    - **索引属性(Indexed Property)**:当属性是集合类型时,可以使用索引进行访问。通过`getIndexedProperty`和`setIndexedProperty`方法可以获取或设置指定索引位置的元素。 ```java Employee subordinate = ...

    beanutils高手学习笔记,重要的学习笔记,想提高的看

    - **Indexed**:针对数组和列表等索引类型,如`propertyName[index]`,可以对数组或列表中的元素进行操作。 - **Mapped**:用于处理Map类型,例如`propertyName[key]`,可以访问和修改Map中的键值对。 3. **...

    详解Java的Hibernate框架中的搜索工具的运用

    SSH(Struts、Spring、Hibernate)是经典的三大框架组合,其中Hibernate负责数据层的管理。本篇文章将深入探讨Hibernate框架中的搜索工具,特别是其全文索引功能。 首先,要启用Hibernate的全文搜索功能,我们需要...

    基于Springboot的漫画网站--论文.zip

    Java项目基于springboot的课程设计,包含源码+数据库+毕业论文

    Java毕业设计-SpringBoot+Vue的分布式架构网上商城(附源码、数据库、教程).zip

    Java 项目, Java 毕业设计,Java 课程设计,基于 SpringBoot 开发的,含有代码注释,新手也可看懂。毕业设计、期末大作业、课程设计、高分必看,下载下来,简单部署,就可以使用。 包含:项目源码、数据库脚本、软件工具等,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行! 1. 技术组成 前端:html、javascript、Vue 后台框架:SpringBoot 开发环境:idea 数据库:MySql(建议用 5.7 版本,8.0 有时候会有坑) 数据库工具:navicat 部署环境:Tomcat(建议用 7.x 或者 8.x 版本), maven 2. 部署 如果部署有疑问的话,可以找我咨询 Java工具包下载地址: https://pan.quark.cn/s/eb24351ebac4 后台路径地址:localhost:8080/项目名称/admin/dist/index.html 前台路径地址:localhost:8080/项目名称/front/index.html (无前台不需要输入)

    GUI面板MATLAB漂浮物识别.zip

    GUI面板MATLAB漂浮物识别

    【工程项目】MATLAB道路桥梁裂缝检测[不同类型,GUI界面,Bp算法].zip

    【工程项目】MATLAB道路桥梁裂缝检测[不同类型,GUI界面,Bp算法]

    Delphi 12.3控件之高仿银豹手机APP 1.0.zip

    Delphi 12.3控件之高仿银豹手机APP 1.0.zip

    springboot高校食堂移动预约点餐系统.zip

    ava项目springboot基于springboot的课程设计,包含源码+数据库+毕业论文

    基于SSM+JSP的定西扶贫惠农推介系统+数据库(Java毕业设计,包括源码,教程).zip

    Java 项目, Java 毕业设计,Java 课程设计,基于 SpringBoot 开发的,含有代码注释,新手也可看懂。毕业设计、期末大作业、课程设计、高分必看,下载下来,简单部署,就可以使用。 包含:项目源码、数据库脚本、软件工具等,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行! 1. 技术组成 前端:jsp 后台框架:SSM 开发环境:idea 数据库:MySql(建议用 5.7 版本,8.0 有时候会有坑) 数据库工具:navicat 部署环境:Tomcat(建议用 7.x 或者 8.x 版本), maven 2. 部署 如果部署有疑问的话,可以找我咨询 Java工具包下载地址: https://pan.quark.cn/s/eb24351ebac4

    GUI面板MATLAB指纹识别.zip

    GUI面板MATLAB指纹识别

    【工程项目】MATLAB的病虫害检测系统(SVM方法,GUI界面).zip

    【工程项目】MATLAB的病虫害检测系统(SVM方法,GUI界面)

    基于ssm+vue的药品商超管理系统(java毕业设计,包括源码,数据库,教程).zip

    Java 项目, Java 毕业设计,Java 课程设计,基于 SSM 开发的,含有代码注释,新手也可看懂。毕业设计、期末大作业、课程设计、高分必看,下载下来,简单部署,就可以使用。 包含:项目源码、数据库脚本、软件工具等,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行! 1. 技术组成 前端:vue/html5 后台框架:SSM 开发环境:idea 数据库:MySql(建议用 5.7 版本,8.0 有时候会有坑) 数据库工具:navicat 部署环境:Tomcat(建议用 7.x 或者 8.x 版本), maven 2. 部署 如果部署有疑问的话,可以找我咨询 Java工具包下载地址: https://pan.quark.cn/s/eb24351ebac4

    Java毕业设计-SpringBoot+Vue的旅游管理系统(附源码,数据库).zip

    Java 项目, Java 毕业设计,Java 课程设计,基于 SpringBoot 开发的,含有代码注释,新手也可看懂。毕业设计、期末大作业、课程设计、高分必看,下载下来,简单部署,就可以使用。 包含:项目源码、数据库脚本、软件工具等,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行! 1. 技术组成 前端:html、javascript、Vue 后台框架:SpringBoot 开发环境:idea 数据库:MySql(建议用 5.7 版本,8.0 有时候会有坑) 数据库工具:navicat 部署环境:Tomcat(建议用 7.x 或者 8.x 版本), maven 2. 部署 如果部署有疑问的话,可以找我咨询 Java工具包下载地址: https://pan.quark.cn/s/eb24351ebac4 后台路径地址:localhost:8080/项目名称/admin/dist/index.html 前台路径地址:localhost:8080/项目名称/front/index.html (无前台不需要输入)

    Java毕业设计-SpringBoot+Vue的基于SpringBoot的CSGO赛事管理系统(附源码、数据库、教程).zip

    Java 项目, Java 毕业设计,Java 课程设计,基于 SpringBoot 开发的,含有代码注释,新手也可看懂。毕业设计、期末大作业、课程设计、高分必看,下载下来,简单部署,就可以使用。 包含:项目源码、数据库脚本、软件工具等,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行! 1. 技术组成 前端:html、javascript、Vue 后台框架:SpringBoot 开发环境:idea 数据库:MySql(建议用 5.7 版本,8.0 有时候会有坑) 数据库工具:navicat 部署环境:Tomcat(建议用 7.x 或者 8.x 版本), maven 2. 部署 如果部署有疑问的话,可以找我咨询 Java工具包下载地址: https://pan.quark.cn/s/eb24351ebac4 后台路径地址:localhost:8080/项目名称/admin/dist/index.html 前台路径地址:localhost:8080/项目名称/front/index.html (无前台不需要输入)

    2023年计算机组成与维护教程题库及答案.pdf

    2023年计算机组成与维护教程题库及答案.pdf

    本文章是本人在学习初阶数据结构的随手笔记,不具有任何教学功能,仅供参考

    本文章是本人在学习初阶数据结构的随手笔记,不具有任何教学功能,仅供参考

    #深度学习环境配置#CUDA+CUDNN+pycharm

    #深度学习环境配置#CUDA+CUDNN+pycharm

    springboot-时间管理系统 LW PPT.zip

    ava项目springboot基于springboot的课程设计,包含源码+数据库+毕业论文

Global site tag (gtag.js) - Google Analytics