Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将Struts2迭代器索引作为映射键提交不起作用_Java_Jsp_Struts2 - Fatal编程技术网

Java 将Struts2迭代器索引作为映射键提交不起作用

Java 将Struts2迭代器索引作为映射键提交不起作用,java,jsp,struts2,Java,Jsp,Struts2,我遇到了一个有趣的问题,我真的不知道它是什么 我有一个struts迭代器,它显示一个文本字段。定义如下: <s:form action="AddSubmit" method="post" theme="simple"> <s:iterator status="rowStatus" value="otherList"> <div> <span>Input V

我遇到了一个有趣的问题,我真的不知道它是什么

我有一个struts迭代器,它显示一个文本字段。定义如下:

    <s:form action="AddSubmit" method="post" theme="simple">
        <s:iterator status="rowStatus" value="otherList">
                <div>
                   <span>Input Value:</span>
                   <s:textfield theme="simple" 
                        name="valueMap[%{#rowStatus.index} + '-custom'].inputValue"/>
                                    </div>
        </s:iterator>
        <s:submit value="Save" theme="simple" />
   </s:form>

输入值:
当我提交时,迭代器值
%{#rowStatus.index}
不会计算为任何值,并且该值从未设置过,但当我硬编码一个键(如
0
)时,它会工作。知道发生了什么事吗

这应该有效:

name="%{'valueMap[\\'' + #rowStatus.index + '-custom\\'].inputValue'}"

%{OGNL expression}
用于强制对通常被解释为字符串文字的属性进行OGNL求值。

对于me@Seephor,那么
name=“%{'valueMap[\\'+\\\'+\\\\\\\\'+'-rowStatus.index+'-custom\\'].inputValue'}”呢?
嘿,这很有效!好啊那么为什么它需要像这样包装呢?令人惊讶的是,如果我在定制之前有“-”,它就不起作用了,但是它没有。需要逃走吗?我尝试了“\\-custom\\”,但没有成功。@Seephor,令人惊讶的是,请您尝试一下
\
(下划线)好吗。其他任何内容都不计算。