spring mvc - Strings with double quotes in messages.properties are not displayed correctly -


i doing spring web application. in messages.properties file, there one-line string follows:

label.name.tooltip=the "name" field ... 

my jsp file displays string follows:

<spring:message code="label.name.tooltip" /> 

however, displayed text "the", means part "name" cut.

i dont know why happens. googled , ways such adding backslash before double quotes not working.

regards , thanks!

update

the whole problem caused me using string in title attribute of tag follows:

a href="#" data-toggle="tooltip" title="<spring:message code="label.name.tooltip" /> 

as bossie hinted, browser removes string content starting double quote.

misha did quite explanation, helped me understand more how message works. thanks, misha!!!

i found solution @ in case, use "name" instead of double quotes. hope helps else.

spring resolves message codes using messagesource, in turn uses messagesourcesupport object. if message victim of application of messageformat rules (defined here), can escape double quotes using single quotes:

the '"'name'"' field should not null, empty, or start integer. 

unfortunately, messageformat doesn't state double quotes special characters, shot in dark.

edit:

alright. went , tried it. have no problems loading double quotes as-is. messages.properties has 1 line:

test.message = "hello, world!" 

and test looks this:

@runwith(springjunit4classrunner.class) @contextconfiguration(classes = testconfiguration.class) public class testquotes {      @autowired     private messagesource source;      @test     public void test() {         assertequals(             "\"hello, world!\"",              source.getmessage("test.message", null, locale.us));     } } 

therefore, conclusion .jsp processor consumes double quotes - it's not message source-related objects. don't know object renders .jsp, should take closer see rules has parsing injected values (and maybe try double-double quotes or something).


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -