Enconding problem: JSTL fmt

Asked

Viewed 191 times

0

I’m using fmt to internationalize the texts on a page. It turns out that when using accents, the text gets weird characters. I tried to change:

<fmt:requestEncoding value="UTF-8" />

but there was no difference. There is some extra configuration that should be made?

Edit:

Header on the page

<%@ page contentType="text/html; charset=UTF-8" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setLocale value="pt_BR"/>
<fmt:setBundle basename="messages" />

Utilizing:

<h5><fmt:message key="action"/></h5>

messages_pt_BR.properties file:

action = Ação
  • would be this here?

  • So it works! But the project was using normal accent, when I got the project via git, the encoding of . properties came broken (with queries) and started not to work accent. I use a machine with Macos, will there be any relation?

1 answer

0

No use just changing the encoding on the tag fmt if the displayed information is saved using another encoding. Checks the encoding used in the database or language files you are using to load the information displayed on that screen. If you need to modify the encoding, you will need to modify it also in the data source to make it compatible with the tag fmt.

  • I am loading from a file, in case, messages_pt_BR.properties . In it I have only a text file with the format: tag = text . I do not define any encoding in the file, but using "text" accentuation fmt loads wrong. If I put it in "ISO-8859-1" format, the text is loaded correctly. This is what led me to believe that fmt is missing the text in ISO format despite the configuration of requestEncoding.

  • So, you created your properties with eclipse? If yes see there the encoding selected pro Workspace. In the editors always have a selected encoding.

  • The file is encoding UTF-8, I checked here.

  • Specifies the header of the generated html page to see if the setted encoding is UTF-8 itself.

  • Also. Apparently everything is encoding UTF-8, maybe it’s some fmt pattern. In the last case I will create all my properties using ISO, but it is not practical, since in English there is a lot of accentuation.

  • It is never good to use this ISO! I speak from my own experience. Post the content of the text you are displaying and the page to try to simulate here.

  • I made an Edit, take a look.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.