3

In my spring-mvc project I want to display english language and Hindi language together.example :

 Hello Sir, आप कैसे है??  (English language,Hindi language)

So,I have style.css:--

  @font-face {  
      font-family: 'kruti dev' ;  
      src: url( '../fonts/k010.ttf' ) format("truetype");  
    } 
.texts {
    position: relative;
    margin: 10px auto;
    font-family: ' kruti dev';

}

I have "message.properties" on WEB-INF folder. message.properties is:

text = Hello Sir,
text_hi=\u0906\u092A \u0915\u0948\u0938\u0947 \u0939\u0948?

I have spring-servlet.xml

<bean id="messageSource"
        class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="/WEB-INF/messages" />
         <property name="defaultEncoding" value="UTF-8" />

    </bean>

I am using maven,So,In Pom.xml I have:

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

In my jsp page I have:

    <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<section >
    <spring:message code="text"/> <spring:message code="text_hi"/>
</ssection>

But the message is showing as question mark..(????).. why??

Salini
  • 357
  • 2
  • 20
  • 1
    Is your webpage in UTF-8 (i.e. a META-INF tag with the appropriate charset). You might want to configure a `CharacterEncodingFilter` as the first filter and force the encoding to UTF-8. – M. Deinum Aug 17 '15 at 06:55
  • http://stackoverflow.com/questions/6638284/spring-mvc-response-encoding-issue – seenukarthi Aug 17 '15 at 06:55
  • 2
    It should work actually as per the steps you followed. Try putting `<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>` – prem30488 Aug 17 '15 at 06:58
  • Yes you are right..Thank you..@ M. Deinum ,@ Parth Trivedi , – Salini Aug 17 '15 at 06:59
  • http://stackoverflow.com/questions/22297858/gujarati-font-not-displayed-correctly/23446761#23446761 – prem30488 Aug 17 '15 at 06:59
  • You can also instruct your application-server i.e Apache tomcat or so to use UTF-8. In JSP's, you might require to mention encoding as UTF-8. – We are Borg Aug 17 '15 at 07:22

1 Answers1

1

Actually gujarati,hindi etc. fonts are in utf-8 format. If you are using Hindi then in your html page following line should be there.

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

But you should remove other specifications like if you are using jsp page than

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

line should be removed because you are specifying in meta tag. You need only meta tag.

prem30488
  • 2,828
  • 2
  • 25
  • 57