互相使用两个 struts2 标签库
我想彼此使用两个struts taglib,如下所示:
< s:property value="url-< s:property value="number"/>"/>
或者
< s:property value="url-${number}"/>
但在第二个中出现以下错误:
根据标签文件中的TLD或属性指令,属性值不接受任何表达式。
有人有解决办法吗?
谢谢
I want to use two struts taglib in each other, something like this:
< s:property value="url-< s:property value="number"/>"/>
or
< s:property value="url-${number}"/>
but I got the following error in the second one:
According to TLD or attribute directive in tag file, attribute values does not accept any expressions.
Anybody has a solution ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您还可以使用
Struts 接受格式为 %{yourAttribute} 的 OGNL 表达式
you can also use
Struts accepts OGNL expressions in the format %{yourAttribute}
如果“
number
”值是固定的(在生成jsp时;即没有在jsp中设置,或在迭代器中更改),则最好将其重构为方法在你的行动中。例如,如果“number
”是您操作中的属性:在其他地方您可以尝试(未经测试)
或类似的操作。
If the "
number
" value is fixed (at the moment of the jsp generation; i.e., it is not set in the jsp, or changed in an iterator), you'd better refactor it to a method in your action. For example, if the "number
" is a property in your action:elsewhere you could try something as (untested)
or something like that.
解决方案太简单了!
正如我们的朋友 leonbloy 所说,当数字在迭代器中生成时,它现在位于值堆栈中。
所以我应该写它的名字:
The Solution was too easy!
As our friend leonbloy said, number is now in value stack when it generated in an iterator.
so I should just write it's name: