I am working on a Spring JSR 286 Portlet application. The locale is driven by a default language setting that is loaded upon login.
I then need to do currency formatting through the portlet. For example, I do the following:
<fmt:setLocale value="en_IE" />
result: <fmt:formatNumber type="currency" value="324.00" currencyCode="EUR" />
(Normally, all these values are set dynamically.)
This produces a fine result as I go through the normal operation.
result: €324.00
Except, in the application, when I do a @ResourceMapping
request. In this case, and here only, I get:
result: ?324.00
I've got the same two lines in the jsp's that render for RenderRequest
s and in the jsp's that render for ResourceRequest
s. But regardless of what I do, it always fails to produce clean output as part of a ResourceRequest
.
Any ideas as to what could be causing the inconsistency?
2nd EDIT:
Following on +BalusC 's 2nd comment, I put the following into the jsp:
<% System.out.println("Response Char Encoding: " + response.getCharacterEncoding()); %>
For regular requests where, it works, I get:
SystemOut O Response Char Encoding: UTF-8
For Render Requests, where it doesn't work, I get:
SystemOut O Response Char Encoding: ISO-8859-1
So, yes, as predicted, this is a character encoding issue.
--
EDIT 3:
So, the issue is how to set a character encoding of UTF-8 in Spring on a ResourceResponse
.
Putting in a page directive of <%@page pageEncoding="UTF-8"%>
doesn't override the default encoding seen above. The methods for building this directly into Spring are complicated hacks (see Spring Encoding with CharacterEncodingFilter in web.xml ), and given that I have only a handful of Resource Request methods, it seems the easiest way is to just put
response.setCharacterEncoding("UTF-8");
into those methods.
Would appreciate any other suggestions, especially if I'm wrong about how to more easily put this into Spring.