I'm having some issues including parameters with special characters in a <s:url/>
struts2
tag.
Params inside a <s:form/>
, either as hidden or explicit fields are behaving just fine although some can have special characters, but the trouble comes when I try to append any param which contains special characters (in this case 'é') to a struts2
URL and trigger an action with it.
This is the <s:url/>
:
<s:url var="urlRegular" action="fetchUserServices" escapeAmp="false">
<s:param name="username" value="%{username}" />
<s:param name="type" value="%{type}"/>
</s:url>
Debugging with Eclipse, whenever the method fetchUserServices
is called, the parameter username
, which should be 'cInglés', appears to be stored as 'cInglés' , and thus I guess it's not decoded properly from UTF-8
comming from the HTTP
request.
Inside the HTTP
request I can see the parameter username
is encoded and sent like this:
myPath/fetchUserServices.action?username=cIngl%C3%A9s&type=1
So, it appears to me that it's successfully sent to the controller from the view..
I have also tried specifying the username
parameter like this, but with no luck:
<s:url var="urlRegular" action="fetchUserServices" escapeAmp="false">
<s:param name="username" >
<s:property value="%{username}" />
</s:param>
<s:param name="type" value="%{type}"/>
</s:url>
this just changes the way it behaves, and if I use that notation, the param is now encoded on the url like this (XHR
request):
myPath/fetchUserServices.action?username=%5BcIngl%26eacute%3Bs%5D&type=1
And my fetchUserServices
method receives it this way: cIngl&\eacute;s (without the '\', I had to use it because markdown language used here decodes it as cInglés).
At this point I'm a little bit lost, all my pages specify UTF-8
encoding and params with special characters aren't an issue when they go inside a <s:form />
tag.
How can I fix this and have my parameter decoded on my fetchUserServices
method?
Question update: Tried this solution here which suggests using the Spring character encoding filter
but it didn't work either.