java - How can I put a less-than symbol into a ChoiceFormat pattern? -


i have message i'd throw html page, , i'd sensitive number of things bring printed. java.text.choiceformat rescue, right?

text.messages=you have {0,choice,1#<b>one</b> message|1<<b>{0}</b> messages} waiting 

this result in error in choiceformat's constructor:

 java.lang.illegalargumentexception: choice pattern incorrect: 1#<b>one</b> message|1<'<b>'{0}'</b>' messages 

i've narrowed-down problem < symbol in message. no problem: i'll use messageformat's quoting capabilities fix that:

text.messages=you have {0,choice,1#'<b>'one'</b>' message|1<'<b>'{0}'</b>' messages} waiting 

unfortunately, fails:

java.lang.illegalargumentexception: choice pattern incorrect: 1#<b>one</b> message|1<''<b>''{0}''</b>'' messages 

note how single-quote characters (escape characters messageformat) doubled in error message. feel i'm close, can't seem find documentation explains how use special characters < in choiceformat pattern.

here's full stack trace when fails:

caused by: java.lang.illegalargumentexception: choice pattern incorrect: 1#''<b>''one''</b>'' message|1<''<b>''{0}''</b>'' messages         @ java.text.messageformat.makeformat(messageformat.java:1519)     @ java.text.messageformat.applypattern(messageformat.java:479)     @ java.text.messageformat.<init>(messageformat.java:362)     @ org.apache.struts.util.messageresources.getmessage(messageresources.java:305)     @ org.apache.velocity.tools.struts.messagetool.get(messagetool.java:158)     @ org.apache.velocity.tools.struts.messagetool.get(messagetool.java:125)     @ org.apache.velocity.tools.struts.messagetool.get(messagetool.java:192) [...] 

you on right track, didn't quote of them:

text.messages=you have {0,choice,1#'<b>'one'</b>' message|1<'<b>'{0}'</b>' messages} waiting 

or:

text.messages=you have {0,choice,1#'<b>one</b> message'|1<'<b>'{0}'</b> messages'} waiting 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -