Using within OGNL is being displayed as and not a space
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.
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
instead of  
for easy formatting and giving spaces anywhere you want , in struts framework too,and avoiding too much complexities.
精彩评论