2

I'm new to spring, and I'm trying to print a list. When the page loads, the text doesn't display correctly.

When I replace the return string from the jsp view name with one of the entries and adding the @ResponseBody annotation, it display correctly on the browser (FF set to UTF-8).

I'm working on ubuntu, so files are saved on utf-8 and tomcat server.xml URIEncoding is set to UTF-8. I've also added the line

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

to the pom.xml

jsp:

<c:forEach var="current" items="${ entries }">
    <H1><c:out value="${current.getCsvRow() }"></c:out></H1>
</c:forEach>

Iterating using <%= item %> isn't displaying right as well. However, writing hebrew directly on the JSP displays correctly.

UPDATE: My jsp is configured to display UTF-8 using

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

Any suggestions??

OBY Trance
  • 59
  • 1
  • 1
  • 10
  • What exactly mean "not correct"? Could you please add an example. And which exact tomcat version do you use (I ask because I have had an encoding problem in 7.0.47 yesterday) – Ralph Dec 12 '13 at 06:40
  • 1
    I'm getting: `×ש ×× ××§×?` while I should have get `יש לך דקה?` – OBY Trance Dec 12 '13 at 21:10

1 Answers1

0

This is not actually a spring problem, but rather a jsp/http problem. The content-type and character set have to be set correctly in the HTTP response. The formatting of the files on disk is one thing, but the HTTP responses have to be both encoded and designated as UTF-8, or the client browser risks not rendering the response correctly.

The easiest way for you to do this is to add a page directive to the first line of the jsp page:

<%@page contentType="text/html; charset=UTF-8"%>
Sean Reilly
  • 21,526
  • 4
  • 48
  • 62