I have an issue in a JSP page where I have to display a generated message onscreen based on a string. It all works fine until one of the account numbers contains two spaces.
So, I have this HTML:
<logic:notEqual name="migrationsMessage" value="">
<div style="color:Red;font-weight:bold">
<bean:write name="solasDetailsForm" property="migrationsMessage"/>
</div>
</logic:notEqual>
When the field migrationsMessage contains this:
<input type="hidden" name="migrationsMessage" value="A 123456W has migrated to A 123456.">
The output on the screen is this:
“A 123456W has migrated to A 123456.”
The second space after the first A is removed. I tried to alter the style to be this but it didn't help:
<logic:notEqual name="migrationsMessage" value="">
<div style="color:Red;font-weight:bold;white-space:pre">
<bean:write name="solasDetailsForm" property="migrationsMessage"/>
</div>
</logic:notEqual>
Any ideas what is going wrong?
white-space: break-spaces
solved for me. More on white-spaces here. They have this awesome table:
function encodeWhiteSpaces(str) {
return str.split('').map(function(c) { return c === ' ' ? ' ' : c }).join('');
}
The string is converted to an array(split
), then created a new arrray (map
) with all white spaces converted to
, finally join the array back to a string (join
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With