Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add dynamic parts in texts

When I try to put some dynamic parts in my texts to be used by <s:text> tag in Struts 2, these parts are replaced by the params I defined.

Here is how I write my sentences in my file.properties:

my_error=The event {0} doesn't exist

Here is how I try to display it:

<s:text name="my_error">
    <s:param>Event01</s:param>
</s:text>

But in the result, the expression {0} is NOT replaced and I have no error in the log. What's wrong?

like image 353
Florent06 Avatar asked May 29 '13 06:05

Florent06


1 Answers

I really can't understand. I picked this example, so I have this in my jsp file:

<s:text name="msg.error">
    <s:param >Event01</s:param>
</s:text>
<br />
<s:text name="name.msg.param" >
    <s:param >mkyong</s:param>
</s:text>

and this in my .properties:

msg.error = This event doesn't exist: {0}
name.msg.param = This is a message from properties file - param : {0}

But the result is:

This event does not exist: {0}
This is a message from properties file - param : mkyong

I do not manage to find a real difference.

like image 162
Florent06 Avatar answered Oct 03 '22 03:10

Florent06