PDA

View Full Version : How to reserve balnk space in ${status.value}


scott
Mar 20th, 2006, 01:12 PM
In a JSP page, I try to output a value:

<spring:bind path="displayList">
${status.value}
</spring:bind>

This works fine, except I have some blank space issue. The above displayList carry a value of concatenated string, such as:

aaa bbb ccc ddd

I want to reserve 2 blank spaces betwen aaa and bbb, while 4 blank spaces betwen ccc and ddd.

But when displayed, there is always only 1 blank space reserved. How can I realize the above, or how can I control how many space to reserve?

NOTE: I can NOT use the &nbsp; for the concatenated string aaa bbb ccc ddd is a string value set to the variable: displayList.


Thanks to help.

mrshlthmps
Mar 20th, 2006, 01:16 PM
Wrap it with the html <pre></pre> tag

scott
Mar 20th, 2006, 01:36 PM
Thanks for the help.

ryan.berdeen@gmail.com
Mar 21st, 2006, 12:12 AM
You might want to use the jstl replace function: ${fn:replace(status.value, "-", "&nbsp;")}

Take a look at http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fn/replace.fn.html

Alternatively, you could use the white-space css property if you don't want the text in a block: <span style="white-space: pre">${status.value}</span>