Return String result type from Struts2. Problem with encoding
I've written an action that returns a string. The returned string is an xml-string.
E.g. I'd like to return this xml, but I rece开发者_如何学JAVAive this UTF-8 format: <request><id>6</id>
This is the xslt file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="result">
<response>
<receiver>
<xsl:value-of select="retString"/>
</receiver>
</response>
</xsl:template>
</xsl:stylesheet>
And struts file:
<action name="retString" method="retString"
class="it.whereareyou.action.RequestAction">
<result type="xslt" name="success">
<param name="stylesheetLocation">request.xslt</param>
<param name="matchingPattern">^/result/[^/*]$</param>
</result>
<result name="error">error.jsp</result>
</action>
The action is invoked and the getter and setter methods are wellformat... The string is returned, but in this format <request>
instead of <request>
.
精彩评论