Reputation: 211
All the data on the page are displayed correctly. Text, to get out of the database, including. But when the form is submitted, the controller comes in text windows- 1252.
In jsp encoding specified.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
For form too.
<form:form method="POST" action="/event" modelAttribute="message" acceptCharset="UTF-8">
Filter in web.xml
<filter>
<filter-name>encoding-filter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding-filter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
What could be the problem?
Upvotes: 1
Views: 487
Reputation: 211
This problem occurs if CharacterEncodingFilter is not first. In my case it was to blame spring security
. After all configuration moved from java config
to xml
and set CharacterEncodingFilter before filter spring security
, data started coming in the correct encoding.
Upvotes: 1