struts2中需要的简单OGNL投影
我想创建一个非常简单的标签,用集合的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很笨。
就是这样,我错过了我使用了错误的类,它根本没有 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 :)