java - Spring and XSLT, character encoding -


i have problem proper charset encoding part of html view. xsl file in jsp files generates .html. values database encoded correct, static headers of table contain wrong characters.

for example, there headers named: imię, nazwisko, hasło, płeć, generates: imiÄ™, nazwisko, hasÅ‚o, pÅ‚eć

my forhomehtml.xml template:

<?xml version="1.0" encoding="utf-8"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" version="1.0">  <xsl:output method="xhtml" encoding="utf-8" indent="yes" doctype-public="-//w3c//dtd xhtml 1.0 strict//en"     doctype-system="http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd" />  <xsl:template match="/">     <xsl:apply-templates /> </xsl:template>  <xsl:template match="/employees">     <table>         <tr>             <th></th>             <th>imię</th>             <th>nazwisko</th>             <th>hasło</th>             <th>płeć</th>         </tr>         <xsl:for-each select="./employee">             <tr>                 <td></td>                 <td>                     <xsl:value-of select="name/text()" />                 </td>                 <td>                     <xsl:value-of select="surname/text()" />                 </td>                 <td>                     <xsl:value-of select="password/text()" />                 </td>                 <td>                     <xsl:value-of select="gender/text()" />                 </td>             </tr>         </xsl:for-each>     </table> </xsl:template> 

jsp site:

<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  <c:import var="inputdocument" url="http://localhost:8080/xyz/home.xml" /> <c:import var="stylesheet" url="/web-inf/xsl/forhomehtml.xsl" />  <x:transform xml="${inputdocument}" xslt="${stylesheet}"> </x:transform> 

i use tiles, encoding declared in main template:

<?xml version="1.0" encoding="utf-8" ?> <%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"     "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <html> <head> <title><tiles:getasstring name="title" /></title> ... 

i add have encoding filter in web.xml

<filter>   <filter-name>encodingfilter</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>encodingfilter</filter-name>   <url-pattern>/*</url-pattern> </filter-mapping> 

character encoding of files (jsp, xsl, xml, etc.) setted utf-8. character encoding of browser setted utf-8.

does know reason of problem?


update: strange, source of site contains following code:

<?xml version="1.0" encoding="utf-8" ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-    transitional.dtd"> <html> <head> <title>strona główna</title> <style type="text/css"> .table-list { border: 1px solid black; border-collapse: collapse; } ... </style> </head> <body> <table width="100%" border="0"> <tr style="background-color: #eeeeee;"> <td><?xml version="1.0" encoding="utf-8" ?> <ul class="navigation_menu"> <li><a href="./home.htm">strona główna</a></li> <li><a href="./rejestracja.htm">rejestracja</a></li> <li><a href="./historia-wypozyczen-samochodu.htm">historia samochodu</a></li> <li><a href="./dodawanie-zamowienia.htm">dodawanie zamówienia</a></li> </ul>  <div style="text-align: center;"> liczba obsłużonych dzisiaj zamówień: 0 </div></td></tr> <tr> <td valign="top" align="left"> <?xml version="1.0" encoding="utf-8"?> <!doctype table public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-    transitional.dtd"> <table xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <tr> <th /> <th>imiÄ&#153;</th> <th>nazwisko</th> <th>hasÅ&#130;o</th> <th>pÅ&#130;eÄ&#135;</th> </tr> <tr> <td /> <td>zenon</td> <td>kowalski</td> <td>zhasło</td> <td>mężczyzna</td> </tr> <tr> <td /></tr> .... <tr style="background-color: #eeeeee;"> <td><?xml version="1.0" encoding="utf-8" ?> <div style="text-align: center;"></div></td></tr> </table> </body> </html> 

there's no content-type header!

should change tiles template?

btw, @alejandro, @jim garrison - tips.

it seems if jstl either not reading or outputting utf-8 data correctly. found several reports of issues utf-8 data , jstl transforms, not lot of solutions.

i did find this page describing similar problem jstl , utf-8 support. solution switch transformers , use saxon.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -