character encoding UTF-8 not working

0

I know the issue has been commented on numerous blogs and forums around the world, but I really do not know what it might be causing, because I think everything in my project configuration is ok:

pages * .jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<html>
<head>
    <meta charset="utf-8">
    <title>JooceBox v1.0</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

web.xml

<filter>
    <filter-name>SetCharacterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>SetCharacterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

In addition I set as a parameter in the connection to the database itself:

<property name="url" value="jdbc:mysql://localhost:3306/viatgedb?useUnicode=yes&amp;characterEncoding=UTF-8"/>

Even with such settings when I save some record with accents the same is as follows:

'Joà £ o Manuel', 'Galà £ o Bonin'

    
asked by anonymous 07.01.2015 / 17:16

1 answer

2

I solved the problem by following this post .

It seems that in modern browsers at the time the submmit of the form is done by method POST HTTP Accept-Encoding . The default specification of servlets specifies encode Latin-1 / ISO-8859-1 .

Simply put filter SetCharacterEncodingFilter into web.xml as the first one in the file.

For requests of the GET type, just edit the tag <connector> server.xml file Apache Tomcat >) by adding the following attributes: URIEncoding="UTF-8" useBodyEncodingForURI="true"

    
19.06.2015 / 21:42