开发者

Using   within OGNL is being displayed as   and not a space

开发者 https://www.devze.com 2023-03-11 23:23 出处:网络
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.

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 + '&nbsp;'}" />
</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 &nbsp;&nbsp;&nbsp;..... 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.


You forgot escapeHtml.

<s:property value="#blanks" escapeHtml="false" />  

or just

${blanks}


escapeHtml / escape (Deprecated) : default is true



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)


Just use &nbsp; instead of &nbsp for easy formatting and giving spaces anywhere you want , in struts framework too,and avoiding too much complexities.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号