struts2中需要的简单OGNL投影

发布于 2024-09-24 18:48:32 字数 1045 浏览 3 评论 0原文

我想创建一个非常简单的标签,用集合的 id 进行参数化,如下所示:

<s:url action="theaction" namespace="/" includeParams="all" id="histURL">
 <s:param name="sources" value="sources.{id}"></s:param>
</s:url>
${histURL}

如果我在 Action 类中定义了三个 Source 对象,其 id 为 1,2 和 3,那么我假设,histURL 输出将是 sg像:

http://localhost:8080/myproject/theaction&sources=1&sources=2&sources=3

但它不起作用,它显示:

http://localhost:8080/myproject/theaction

另一个提示:

<s:url action="theaction" namespace="/" includeParams="all" id="histURL">
 <s:param name="sources" value="sources"></s:param>
</s:url>
${histURL}

导致

http://localhost:8080/myproject/theaction&sources=com.mycompany.Source@32324&sources= ...

所以集合作为参数起作用,我只是假设 OGNL 投影 效果很好,但似乎有问题。或者我错过了什么?这是 OGNL 吗? :)

谢谢您的回复!

I would like to create a really simple tag parameterized with a collections' ids something like the following:

<s:url action="theaction" namespace="/" includeParams="all" id="histURL">
 <s:param name="sources" value="sources.{id}"></s:param>
</s:url>
${histURL}

If I have say three Source objects defined in my Action class, having ids 1,2 and 3 then I assume, the histURL output will be sg like:

http://localhost:8080/myproject/theaction&sources=1&sources=2&sources=3

But it does not work, it displays:

http://localhost:8080/myproject/theaction

Another hint:

<s:url action="theaction" namespace="/" includeParams="all" id="histURL">
 <s:param name="sources" value="sources"></s:param>
</s:url>
${histURL}

results in

http://localhost:8080/myproject/theaction&sources=com.mycompany.Source@32324&sources= ...

So the collection as a paramater works, I just assumed that the OGNL projection works well but seems to be buggy. Or am I missing something? Is this OGNL at all? :)

Thank you for your replies!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩动你心 2024-10-01 18:48:32

我很笨。
就是这样,我错过了我使用了错误的类,它根本没有 Id。
这绝对是 OGNL,而且很有魅力:)

I'm dumb.
This is just the way, I missed that I used a wrong class, which had no Id at all.
It's definitely OGNL and it works like charm :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文