简体   繁体   English

ognl'in'语句未按预期运行

[英]ognl 'in' statement not functioning as expected

I have the following code: 我有以下代码:

<s:iterator value="primaryDataSources" var="includedPrimaryDataSource">
    <s:property value="%{includedPrimaryDataSource in primaryDataSources}"/>
</s:iterator>

with primaryDataSources being an ArrayList initialised in my action class: 与primaryDataSources是在我的动作类中初始化的ArrayList:

List<String> primaryDataSources = new ArrayList<String>(Arrays.asList(new String[]{"SE", "QBP", "Olympic", "J&B"}));

When I output primaryDataSources on its own like this: 当我像这样自行输出primaryDataSources时:

 <s:property value="%{primaryDataSources}"/>

it outputs [SE, QBP, Olympic, J&B] 它输出[SE,QBP,Olympic,J&B]

I would expect that the 'in' ognl statement would always return true, however it is always false... Any idea what I'm doing wrong? 我希望'in'ognl语句始终返回true,但是始终为false ...知道我在做什么错吗?

You are missing # to reference your includedPrimaryDataSource , also %{...} is not needed inside <s:property> tag. 您缺少#引用您的includedPrimaryDataSource ,在<s:property>标记内也不需要%{...}

<s:iterator value="primaryDataSources" var="includedPrimaryDataSource">
    <s:property value="#includedPrimaryDataSource in primaryDataSources"/>
</s:iterator>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM