Question

I am using the Iso-8859-1 character encoding because I got some characters or strings in the database that is encoded in latin1. After I included all the database entries and placed it in the JSP page, there is no problem.

The real problem is that, when I input a german umlaut (ä,ü,...), I get always some strange characters after rendering the JSP page. I tried different filtering options in the web.xml with CharacterEncoding from Spring Framework. Didn't work. I also included the iso-8859-1 content type and page encoding in my JSP file. No success.

I have to say that I include the header JSP file in the body, and the strange characters are rendered after submitting the search form ... displayed ü for ü

I tried it with UTF-8: (ü is rendered to ü)

Here is my JSP file:

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@page contentType="text/html; charset=iso-8859-1" pageEncoding="iso-8859-1"%>
<html>
<head>
    <tiles:insertAttribute name="javascripts" />
    <tiles:insertAttribute name="stylesheets" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title><tiles:insertAttribute name="title" ignore="true" /></title>
</head>
<body>
    <tiles:insertAttribute name="header" />

The rest of the body should be uninteresting. Thank you for help.

I tried following filter: Don't know why it doesn't work ...

<filter>
    <filter-name>SetCharacterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>ISO-8859-1</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>

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top