这是我的代码,我得到一个错误,任何人都可以告诉我原因是什么?
<s:select label="Index" name="index" list="%{#{}}">
<s:iterator value="#session.subscription_countries" var="slist">
<s:property/>
<s:if test='#slist=="CANADA" || #slist=="ALL"'>
<s:optgroup label="Canada" list="%{#{'TSX':'TSX'}}" />
</s:if>
<s:if test='#slist=="UK" || #slist=="ALL"'>
<s:optgroup label="United Kingdom" list="%{#{'FTSE100':'FTSE100'}}" />
</s:if>
<s:if test='#slist=="USA" || #slist=="ALL"'>
<s:optgroup label="USA" list="%{#{'S&P500':'S&P500'}" />
</s:if>
<s:if test='#slist=="INDIA" || #slist=="ALL"'>
<s:optgroup label="India" list="%{#{'NIFTY':'NIFTY','CNX100':'CNX100'}}" />
</s:if>
</s:iterator>
</s:select>
错误
freemarker.core.InvalidReferenceException: Expression optGroupInternalListUiBean.parameters.list is undefined on line 36, column 8 in template/simple/optgroup.ftl.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:100)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:167)
at freemarker.core.Environment.visit(Environment.java:416)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.Environment.include(Environment.java:1482)
at freemarker.core.Include.accept(Include.java:169)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.Environment.include(Environment.java:1482)
at freemarker.core.Include.accept(Include.java:169)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:209
答案 0 :(得分:0)
根据我的理解,你试图从会话中获取列表并将其迭代到框中,如果我是对的,那么你可以试试这个。
“listValue =” 这里 1.list是列表的名称 2.headerKey / headerValue - 没有必要但如果你添加它,它们将出现在你选择框的顶部 3. listKey: - 它将成为你的页面,并且是列表中的类,value是类中的变量,具有值。 4. listValue: - 与listKey相同
如果listKey / listValue是字符串对象,则写入而不是
我希望这会有所帮助 感谢