使用在 OGNL 中显示为 而不是一个空格
我在 jsp 中有以下嵌套的 struts 2 标签。这是在另一个迭代器内,而该迭代器又在 html 表的 td 标记内。
<s:property value="#rule.value" />
<s:set var="blanks" value="''" />
<s:iterator value="(#rule.key.length()).{ #this }">
<s:set var="blanks" value="%{#blanks + ' '}" />
</s:iterator>
<s:property value="#blanks" />
总体目标是渲染您在浏览器中同一行看到的所有 s:property 值。对于某些标签(例如文本字段),您可以更改主题属性,并且它不会尝试在自己的行上打印所有内容。但无论如何,我需要迭代器标记中的所有内容都位于同一行。
所以我在这里想做的是建立一串 nbsp.每次迭代此代码片段时,此类字符串的长度都会发生变化。当我运行它时,迭代器执行正确的次数,但我的输出是
..... 与循环迭代的次数一样多。不过,我需要每个 nbsp 的 html 空间输出。最终,我需要 td 中包含一定数量的字符,以便该表和单独的表在屏幕格式方面保持同步。
I have the following nested struts 2 tags in a jsp. This is within another iterator which is in turn inside a td tag for an html table.
<s:property value="#rule.value" />
<s:set var="blanks" value="''" />
<s:iterator value="(#rule.key.length()).{ #this }">
<s:set var="blanks" value="%{#blanks + ' '}" />
</s:iterator>
<s:property value="#blanks" />
The overall goal is to render all s:property values you see on the same line in the browser. For some tags (like textfield) you can change the theme attribute and it does not try to print everything on its own line. But anyhow, I need everything on the same line within an iterator tag.
So what I am trying to do here is to build up a string of nbsp. The length of such a string will change each time this code snippet is iterated over. When I run this, the iterator executes the correct number of times, but my output is
..... as many times as the loop is iterated. I need an html space output for each nbsp though. Ultimately, I need the td to have a certain amount of characters in it so that this table and a separate table sync up as far as screen formatting goes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您忘记了
escapeHtml
。或者只是
escapeHtml
/escape
(Deprecated) : default istrue
You forgot
escapeHtml
.or just
escapeHtml
/escape
(Deprecated) : default istrue
我不太了解 JSP 标签,但我时不时地会遇到它们...您见过
escapeXml="false"
吗? (在 c:out 标记中使用)I don't know a whole lot about JSP tags, but I come across them every now and again... Have you ever seen
escapeXml="false"
? (used in the c:out tag)只需使用
而不是
即可轻松格式化并在您想要的任何地方提供空格,在 struts 框架中也是如此,并避免太多的复杂性。
Just use
instead of
for easy formatting and giving spaces anywhere you want , in struts framework too,and avoiding too much complexities.