java - Resource bundle display incorrectly utf-8 characters in Placeholder of form:input tag -


in project, i'm using resorce bundle display multi language, ok except it's couldn't display values in placeholder:

<label>     <spring:message code="home.address"/> </label> <spring:message code="home.street" var="bdstreet"/> <form:input id="txtstreet" class="form-control" path="address.street" placeholder="${bdstreet}" /> <form:errors path="address.street" cssclass="error" /> 

english display ok, vietnamese incorrect. config:

<beans:bean id="messagesource" class="org.springframework.context.support.resourcebundlemessagesource">     <beans:property name="basenames">         <beans:list>             <beans:value>language/home</beans:value>         </beans:list>     </beans:property> </beans:bean> <mvc:interceptors>     <mvc:interceptor>         <mvc:mapping path="/**" />         <beans:bean id="localechangeinterceptor"             class="org.springframework.web.servlet.i18n.localechangeinterceptor">             <beans:property name="paramname" value="lang" />         </beans:bean>     </mvc:interceptor> </mvc:interceptors>  <beans:bean id="localeresolver"     class="org.springframework.web.servlet.i18n.cookielocaleresolver">     <beans:property name="cookiename" value="lang" />     <beans:property name="defaultlocale" value="vn_vn" /> </beans:bean> <!-- end resource bundle --> 

vietnamese incorrect english ok

try add defaultencoding property in resourcebundlemessagesource declaration:

<beans:bean id="messagesource" class="org.springframework.context.support.resourcebundlemessagesource">     <beans:property name="basenames">         <beans:list>             <beans:value>language/home</beans:value>         </beans:list>     </beans:property>     <beans:property name="defaultencoding" value="utf-8"/> </beans:bean> 

also, check file stored in utf-8 encoding.

about placeholders. seems, store strings in encoded state. means when you'll show in html, browser automatically decode strings. when you'll show in placeholders, browser nothing, , show them is. solution, don't encode stings in resource. type strings common letters. example:

simple.string=qu&#7889;c gia  // store in format  simple.string=quốc gia  // should store in format 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -