How to access iterator variable in Struts tag?(如何访问 Struts 标签中的迭代器变量?)
问题描述
我正在遍历一个列表并希望访问该值以创建一个文本输入字段.不幸的是,我无法访问 <s:textfield> 标签内的循环变量
I'm looping over a list and want to access the value to create a text input field. Unfortunatley I'm failing to access the loop variable inside the <s:textfield> tag
这是我尝试过的:
  <s:iterator var="tag" value="searchTagList">
    <s:property value="#tag"/>
    <s:textfield key="searchResults.#tag" name="#tag" value="#tag" />
  </s:iterator>
<s:property value=#tag"/> 被正确评估并显示循环变量.但是 <s:textfield> 中的 #tag 永远不会被评估.
The <s:property value="#tag"/> is evaluated correctly and shows the loop variable. But the #tag in the <s:textfield> is never evaluated.
我也尝试用 <s:property value="#tag"/> 代替 #tag 没有成功.
I also tried to put <s:property value="#tag"/> instead of #tag without success.
推荐答案
使用标签的key属性代替三个name,value,标签.至于你已经定义的其中两个,你可以改变
The tag's key attribute used instead of three ones name,value,label. As far as two of them you have already defined, you can change 
<s:textfield label="%{getText('searchResults.'+#tag)}" name="%{#tag}" />
该值由 name 属性检索.您应该为 name 属性中评估的名称提供一个 getter.请注意,如果您的操作扩展了 ActionSupport,则 getText() 可用.而且您必须在名称标签中强制进行名称评估.
The value is retrieved by the name attribute. You should provide a getter for the name evaluated in the name attribute. Note, getText() is available if your action extends ActionSupport. And you have to force name evaluation in the name tag.
这篇关于如何访问 Struts 标签中的迭代器变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何访问 Struts 标签中的迭代器变量?
				
        
 
            
        - 如何使用WebFilter实现授权头检查 2022-01-01
 - Jersey REST 客户端:发布多部分数据 2022-01-01
 - Eclipse 插件更新错误日志在哪里? 2022-01-01
 - Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
 - Java包名称中单词分隔符的约定是什么? 2022-01-01
 - C++ 和 Java 进程之间的共享内存 2022-01-01
 - 从 finally 块返回时 Java 的奇怪行为 2022-01-01
 - 将log4j 1.2配置转换为log4j 2配置 2022-01-01
 - value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
 - Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
 
						
						
						
						
						