1

In my spring app, I am using a properties file for strings, and the spring:message tag. I am having trouble putting spaces between the messages though. Here is an example:

<p>
    <spring:message code="msg.message1" /> <spring:message code="msg.message2" />
</p>

Turns into this:

I am message1.I am message 2.

I would think that the whitespace I put between the message tags would create a space, but it doesnt. I know I can use &nbsp, but I don't want that all over my markup. Any suggestions?

user1007895
  • 3,925
  • 11
  • 41
  • 63
  • Can't reproduce your problem with Spring 3.0.5, unless I use `trimDirectiveWhitespaces="true"` in the page. – madth3 Feb 15 '12 at 02:13

5 Answers5

1

Try a span element. for example

<span class="message"><spring:message code="msg.message1"/></span>
<span class="message"><spring:message code="msg.message2"/></span>

then if you don't get the spacing you want, add a .message (or span.message) class that provides the desired spacing. If you get the spacing you want without adding a class, remove class="message" from the spans.

you could use a &nbsp;, but my personal preference is to avoid such things (or forever they will dominate your destiny :) )

DwB
  • 37,124
  • 11
  • 56
  • 82
1

This has nothing to do with Spring. Neither of the two taglibs has control over the output stream when space in between is printed. I can just speculate on two things:

  • Is a refresh problem. They are not very usual, but sometimes you have to be sure you have cleaned your project, deleted Tomcat's work directory and so on.

  • JSP is configured to trim spaces. This is not the default behavior and it can be configured in a few ways, as you can see here.

Community
  • 1
  • 1
sinuhepop
  • 20,010
  • 17
  • 72
  • 107
1

Try by adding &nbsp; in your properties file at the end of message value

eg.

msg.message1 = I am message1. &nbsp;&nbsp;
Romani
  • 3,241
  • 4
  • 25
  • 28
0

Put the messages into <div> elements?

Use CSS to position them relatively to one another with some border/margin?

Svilen
  • 1,377
  • 1
  • 16
  • 23
0

If you literally want a space between the messages, you will need &nbsp;.

GriffeyDog
  • 8,186
  • 3
  • 22
  • 34