开发者

Return String result type from Struts2. Problem with encoding

开发者 https://www.devze.com 2023-02-27 10:45 出处:网络
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>&lt

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 &lt;request&gt; instead of <request>.

0

精彩评论

暂无评论...
验证码 换一张
取 消