title: How to get some utf-8 characters using hibernate and spring mvc in database?
body: <p>I have developed small server program.
  When I extract tuple from database, some characters become ÇÑ±ÛÃàÁ¦.
  I modify server.xml. However ÇÑ±ÛÃàÁ¦ characters still appear.
  Help me.
  How can I get correct characters?</p>
  
  <p>This is my server.xml. (I use apache tomcat 7.0 server.)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
  
        http://www.apache.org/licenses/LICENSE-2.0
  
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
  --&gt;&lt;!-- Note:  A "Server" is not itself a "Container", so you may not
       define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/server.html
   --&gt;&lt;Server port="8005" shutdown="SHUTDOWN"&gt;
    &lt;Listener className="org.apache.catalina.startup.VersionLoggerListener"/&gt;
    &lt;!-- Security listener. Documentation at /docs/config/listeners.html
    &lt;Listener className="org.apache.catalina.security.SecurityListener" /&gt;
    --&gt;
    &lt;!--APR library loader. Documentation at /docs/apr.html --&gt;
    &lt;Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/&gt;
    &lt;!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html --&gt;
    &lt;Listener className="org.apache.catalina.core.JasperListener"/&gt;
    &lt;!-- Prevent memory leaks due to use of particular java/javax APIs--&gt;
    &lt;Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/&gt;
    &lt;Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/&gt;
    &lt;Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/&gt;
  
    &lt;!-- Global JNDI resources
         Documentation at /docs/jndi-resources-howto.html
    --&gt;
    &lt;GlobalNamingResources&gt;
      &lt;!-- Editable user database that can also be used by
           UserDatabaseRealm to authenticate users
      --&gt;
      &lt;Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/&gt;
    &lt;/GlobalNamingResources&gt;
  
    &lt;!-- A "Service" is a collection of one or more "Connectors" that share
         a single "Container" Note:  A "Service" is not itself a "Container",
         so you may not define subcomponents such as "Valves" at this level.
         Documentation at /docs/config/service.html
     --&gt;
    &lt;Service name="Catalina"&gt;
  
      &lt;!--The connectors can use a shared executor, you can define one or more named thread pools--&gt;
      &lt;!--
      &lt;Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
          maxThreads="150" minSpareThreads="4"/&gt;
      --&gt;
  
  
      &lt;!-- A "Connector" represents an endpoint by which requests are received
           and responses are returned. Documentation at :
           Java HTTP Connector: /docs/config/http.html (blocking &amp; non-blocking)
           Java AJP  Connector: /docs/config/ajp.html
           APR (HTTP/AJP) Connector: /docs/apr.html
           Define a non-SSL HTTP/1.1 Connector on port 8080
      --&gt;
      &lt;Connector URIEncoding="UTF-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/&gt;
      &lt;!-- A "Connector" using the shared thread pool--&gt;
      &lt;!--
      &lt;Connector executor="tomcatThreadPool"
                 port="8080" protocol="HTTP/1.1"
                 connectionTimeout="20000"
                 redirectPort="8443" /&gt;
      --&gt;
      &lt;!-- Define a SSL HTTP/1.1 Connector on port 8443
           This connector uses the BIO implementation that requires the JSSE
           style configuration. When using the APR/native implementation, the
           OpenSSL style configuration is required as described in the APR/native
           documentation --&gt;
      &lt;!--
      &lt;Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
                 maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
                 clientAuth="false" sslProtocol="TLS" /&gt;
      --&gt;
  
      &lt;!-- Define an AJP 1.3 Connector on port 8009 --&gt;
      &lt;Connector URIEncoding="UTF-8" port="8009" protocol="AJP/1.3" redirectPort="8443"/&gt;
  
  
      &lt;!-- An Engine represents the entry point (within Catalina) that processes
           every request.  The Engine implementation for Tomcat stand alone
           analyzes the HTTP headers included with the request, and passes them
           on to the appropriate Host (virtual host).
           Documentation at /docs/config/engine.html --&gt;
  
      &lt;!-- You should set jvmRoute to support load-balancing via AJP ie :
      &lt;Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"&gt;
      --&gt;
      &lt;Engine defaultHost="localhost" name="Catalina"&gt;
  
        &lt;!--For clustering, please take a look at documentation at:
            /docs/cluster-howto.html  (simple how to)
            /docs/config/cluster.html (reference documentation) --&gt;
        &lt;!--
        &lt;Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/&gt;
        --&gt;
  
        &lt;!-- Use the LockOutRealm to prevent attempts to guess user passwords
             via a brute-force attack --&gt;
        &lt;Realm className="org.apache.catalina.realm.LockOutRealm"&gt;
          &lt;!-- This Realm uses the UserDatabase configured in the global JNDI
               resources under the key "UserDatabase".  Any edits
               that are performed against this UserDatabase are immediately
               available for use by the Realm.  --&gt;
          &lt;Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/&gt;
        &lt;/Realm&gt;
  
        &lt;Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"&gt;
  
          &lt;!-- SingleSignOn valve, share authentication between web applications
               Documentation at: /docs/config/valve.html --&gt;
          &lt;!--
          &lt;Valve className="org.apache.catalina.authenticator.SingleSignOn" /&gt;
          --&gt;
  
          &lt;!-- Access log processes all example.
               Documentation at: /docs/config/valve.html
               Note: The pattern used is equivalent to using pattern="common" --&gt;
          &lt;Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &amp;quot;%r&amp;quot; %s %b" prefix="localhost_access_log." suffix=".txt"/&gt;
  
        &lt;Context docBase="server" path="/jinggumdari" reloadable="true" source="org.eclipse.jst.jee.server:server"/&gt;&lt;/Host&gt;
      &lt;/Engine&gt;
    &lt;/Service&gt;
  &lt;/Server&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is my web.xml.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
   &lt;!-- The definition of the Root Spring Container shared by all Servlets and Filters --&gt;
   &lt;context-param&gt;
    &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
    &lt;param-value&gt;/WEB-INF/spring/root-context.xml&lt;/param-value&gt;
   &lt;/context-param&gt;
   
   &lt;!-- Creates the Spring Container shared by all Servlets and Filters --&gt;
   &lt;listener&gt;
    &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
   &lt;/listener&gt;
  
   &lt;!-- Processes application requests --&gt;
   &lt;servlet&gt;
    &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
    &lt;init-param&gt;
     &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
     &lt;param-value&gt;/WEB-INF/spring/appServlet/servlet-context.xml&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
   &lt;/servlet&gt;
    
   &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;
   
   &lt;filter&gt;
    &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt;
    &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;
    &lt;init-param&gt;
     &lt;param-name&gt;encoding&lt;/param-name&gt;
     &lt;param-value&gt;UTF-8&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;init-param&gt;
     &lt;param-name&gt;forceEncoding&lt;/param-name&gt;
     &lt;param-value&gt;true&lt;/param-value&gt;
    &lt;/init-param&gt;
   &lt;/filter&gt;
  
   &lt;filter-mapping&gt;
    &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
   &lt;/filter-mapping&gt;
  
  &lt;/web-app&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is my servlet-context.xml.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns="http://www.springframework.org/schema/mvc"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/mvc
      http://www.springframework.org/schema/mvc/spring-mvc.xsd
          http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context.xsd
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx.xsd"&gt;
   &lt;!-- DispatcherServlet Context: defines this servlet's request-processing 
    infrastructure --&gt;
  
   &lt;!-- Enables the Spring MVC @Controller programming model --&gt;
   &lt;annotation-driven /&gt;
  
   &lt;!-- Handles HTTP GET requests for /resources/** by efficiently serving 
    up static resources in the ${webappRoot}/resources directory --&gt;
   &lt;resources mapping="/resources/**" location="/resources/" /&gt;
  
   &lt;!-- Resolves views selected for rendering by @Controllers to .jsp resources 
    in the /WEB-INF/views directory --&gt;
   &lt;beans:bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
    &lt;beans:property name="prefix" value="/WEB-INF/views/" /&gt;
    &lt;beans:property name="suffix" value=".jsp" /&gt;
   &lt;/beans:bean&gt;
  
   &lt;beans:bean
    class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"&gt;
    &lt;beans:property name="favorPathExtension" value="true" /&gt;
    &lt;beans:property name="ignoreAcceptHeader" value="true" /&gt;
  
    &lt;beans:property name="mediaTypes"&gt;
     &lt;beans:map&gt;
      &lt;beans:entry key="json" value="application/json" /&gt;
      &lt;beans:entry key="html" value="text/html" /&gt;
     &lt;/beans:map&gt;
    &lt;/beans:property&gt;
   &lt;/beans:bean&gt;
  
   &lt;context:component-scan base-package="kr.ac.jbnu.jinggumdari" /&gt;
  
   &lt;beans:bean
    class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" /&gt;
  
   &lt;beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close"&gt;
    &lt;beans:property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
    &lt;beans:property name="url"
     value="jdbc:mysql://localhost:3306/jinggumdari" /&gt;
    &lt;beans:property name="username" value="root" /&gt;
    &lt;beans:property name="password" value="mysql1234" /&gt;
   &lt;/beans:bean&gt;
  
   &lt;!-- Hibernate 4 SessionFactory Bean definition --&gt;
   &lt;beans:bean id="hibernate4AnnotatedSessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
    &lt;beans:property name="dataSource" ref="dataSource" /&gt;
    &lt;beans:property name="annotatedClasses"&gt;
     &lt;beans:list&gt;
      &lt;beans:value&gt;kr.ac.jbnu.jinggumdari.model.Member&lt;/beans:value&gt;
      &lt;beans:value&gt;kr.ac.jbnu.jinggumdari.model.Festival&lt;/beans:value&gt;
      &lt;beans:value&gt;kr.ac.jbnu.jinggumdari.model.FestivalImage&lt;/beans:value&gt;
      &lt;beans:value&gt;kr.ac.jbnu.jinggumdari.model.Interest&lt;/beans:value&gt;
      &lt;beans:value&gt;kr.ac.jbnu.jinggumdari.model.Review&lt;/beans:value&gt;
      &lt;beans:value&gt;kr.ac.jbnu.jinggumdari.model.ReviewImage&lt;/beans:value&gt;
      &lt;beans:value&gt;kr.ac.jbnu.jinggumdari.model.Search&lt;/beans:value&gt;
      &lt;beans:value&gt;kr.ac.jbnu.jinggumdari.model.RouteInfo&lt;/beans:value&gt;
      &lt;beans:value&gt;kr.ac.jbnu.jinggumdari.model.Route&lt;/beans:value&gt;
      &lt;beans:value&gt;kr.ac.jbnu.jinggumdari.model.Writing&lt;/beans:value&gt;
     &lt;/beans:list&gt;
    &lt;/beans:property&gt;
    &lt;beans:property name="hibernateProperties"&gt;
     &lt;beans:props&gt;
      &lt;beans:prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect
      &lt;/beans:prop&gt;
      &lt;beans:prop key="hibernate.show_sql"&gt;true&lt;/beans:prop&gt;
     &lt;/beans:props&gt;
    &lt;/beans:property&gt;
    &lt;beans:property name="packagesToScan" value="com.hibernate.yourpackage" /&gt;
   &lt;/beans:bean&gt;
  
   &lt;beans:bean id="memberDAO" class="kr.ac.jbnu.jinggumdari.DAO.MemberDAOImpl"&gt;
    &lt;beans:property name="sessionFactory"
     ref="hibernate4AnnotatedSessionFactory" /&gt;
   &lt;/beans:bean&gt;
   &lt;beans:bean id="memberService"
    class="kr.ac.jbnu.jinggumdari.serviceImplementation.MemberServiceImpl"&gt;
    &lt;beans:property name="memberDAO" ref="memberDAO"&gt;&lt;/beans:property&gt;
   &lt;/beans:bean&gt;
   
   &lt;beans:bean id="festivalDAO" class="kr.ac.jbnu.jinggumdari.DAO.FestivalDAOImpl"&gt;
    &lt;beans:property name="sessionFactory"
     ref="hibernate4AnnotatedSessionFactory" /&gt;
   &lt;/beans:bean&gt;
   &lt;beans:bean id="festivalService"
    class="kr.ac.jbnu.jinggumdari.serviceImplementation.FestivalServiceImpl"&gt;
    &lt;beans:property name="festivalDAO" ref="festivalDAO"&gt;&lt;/beans:property&gt;
   &lt;/beans:bean&gt;
   
   &lt;beans:bean id="festivalImageDAO" class="kr.ac.jbnu.jinggumdari.DAO.FestivalImageDAOImpl"&gt;
    &lt;beans:property name="sessionFactory"
     ref="hibernate4AnnotatedSessionFactory" /&gt;
   &lt;/beans:bean&gt;
   &lt;beans:bean id="festivalImageService"
    class="kr.ac.jbnu.jinggumdari.serviceImplementation.FestivalImageServiceImpl"&gt;
    &lt;beans:property name="festivalImageDAO" ref="festivalImageDAO"&gt;&lt;/beans:property&gt;
   &lt;/beans:bean&gt;
   
   &lt;beans:bean id="interestDAO" class="kr.ac.jbnu.jinggumdari.DAO.InterestDAOImpl"&gt;
    &lt;beans:property name="sessionFactory"
     ref="hibernate4AnnotatedSessionFactory" /&gt;
   &lt;/beans:bean&gt;
   &lt;beans:bean id="interestService"
    class="kr.ac.jbnu.jinggumdari.serviceImplementation.InterestServiceImpl"&gt;
    &lt;beans:property name="interestDAO" ref="interestDAO"&gt;&lt;/beans:property&gt;
   &lt;/beans:bean&gt;
  
   &lt;beans:bean id="reviewDAO" class="kr.ac.jbnu.jinggumdari.DAO.ReviewDAOImpl"&gt;
    &lt;beans:property name="sessionFactory"
     ref="hibernate4AnnotatedSessionFactory" /&gt;
   &lt;/beans:bean&gt;
   &lt;beans:bean id="reviewService"
    class="kr.ac.jbnu.jinggumdari.serviceImplementation.ReviewServiceImpl"&gt;
    &lt;beans:property name="reviewDAO" ref="reviewDAO"&gt;&lt;/beans:property&gt;
   &lt;/beans:bean&gt;
   
   &lt;beans:bean id="reviewImageDAO" class="kr.ac.jbnu.jinggumdari.DAO.ReviewImageDAOImpl"&gt;
    &lt;beans:property name="sessionFactory"
     ref="hibernate4AnnotatedSessionFactory" /&gt;
   &lt;/beans:bean&gt;
   &lt;beans:bean id="reviewImageService"
    class="kr.ac.jbnu.jinggumdari.serviceImplementation.ReviewImageServiceImpl"&gt;
    &lt;beans:property name="reviewImageDAO" ref="reviewImageDAO"&gt;&lt;/beans:property&gt;
   &lt;/beans:bean&gt;
   
   &lt;beans:bean id="routeDAO" class="kr.ac.jbnu.jinggumdari.DAO.RouteDAOImpl"&gt;
    &lt;beans:property name="sessionFactory"
     ref="hibernate4AnnotatedSessionFactory" /&gt;
   &lt;/beans:bean&gt;
   &lt;beans:bean id="routeService"
    class="kr.ac.jbnu.jinggumdari.serviceImplementation.RouteServiceImpl"&gt;
    &lt;beans:property name="routeDAO" ref="routeDAO"&gt;&lt;/beans:property&gt;
   &lt;/beans:bean&gt;
   
   &lt;beans:bean id="routeInfoDAO" class="kr.ac.jbnu.jinggumdari.DAO.RouteInfoDAOImpl"&gt;
    &lt;beans:property name="sessionFactory"
     ref="hibernate4AnnotatedSessionFactory" /&gt;
   &lt;/beans:bean&gt;
   &lt;beans:bean id="routeInfoService"
    class="kr.ac.jbnu.jinggumdari.serviceImplementation.RouteInfoServiceImpl"&gt;
    &lt;beans:property name="routeInfoDAO" ref="routeInfoDAO"&gt;&lt;/beans:property&gt;
   &lt;/beans:bean&gt;
   
   &lt;beans:bean id="searchDAO" class="kr.ac.jbnu.jinggumdari.DAO.SearchDAOImpl"&gt;
    &lt;beans:property name="sessionFactory"
     ref="hibernate4AnnotatedSessionFactory" /&gt;
   &lt;/beans:bean&gt;
   &lt;beans:bean id="searchService"
    class="kr.ac.jbnu.jinggumdari.serviceImplementation.SearchServiceImpl"&gt;
    &lt;beans:property name="searchDAO" ref="searchDAO"&gt;&lt;/beans:property&gt;
   &lt;/beans:bean&gt;
  
   &lt;beans:bean id="writingDAO" class="kr.ac.jbnu.jinggumdari.DAO.WritingDAOImpl"&gt;
    &lt;beans:property name="sessionFactory"
     ref="hibernate4AnnotatedSessionFactory" /&gt;
   &lt;/beans:bean&gt;
   &lt;beans:bean id="writingService"
    class="kr.ac.jbnu.jinggumdari.serviceImplementation.WritingServiceImpl"&gt;
    &lt;beans:property name="writingDAO" ref="writingDAO"&gt;&lt;/beans:property&gt;
   &lt;/beans:bean&gt;
   
   &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  
   &lt;beans:bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
    &lt;beans:property name="sessionFactory"
     ref="hibernate4AnnotatedSessionFactory" /&gt;
   &lt;/beans:bean&gt;
  &lt;/beans:beans&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>and what is needed more?</p>