0

Grails と Rome を使用して RSS フィードを構築しようとしています。

コントローラーの rss アクションでは、最後のコマンドは次のとおりです。

render(text: getFeed("rss_2.0"), contentType:"application/rss+xml", encoding:"ISO-8859-1 ")  

ただし、フィードの URL に移動すると、ヘッダーは次のようになります。

<?xml version="1.0" encoding="UTF-8"?>
    <rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
    ...

getFeed() の私のコードは次のようなものです:

def getFeed(feedType) {
    def currentFeedURL = params.url

    def items = parserService.parse(new URL(currentFeedURL))

    def feedLink = "http://blablabla"

    def feedEntries = []


    items.each { item ->
        def entryTitle 
        if (item.price != null)
            entryTitle = item.description + " - " + item.price + " euros"
        else 
            entryTitle = item.description

        def itemContent = new SyndContentImpl(type:'text/plain', value: getBody(item))   

        SyndEntryImpl entry = new SyndEntryImpl(title: entryTitle,
                link: item.link,
                publishedDate: item.date,
                description: itemContent)
        feedEntries.add(entry)

    }

    def feed = new SyndFeedImpl(feedType: feedType,
        encoding : "ISO-8859-1",
        title: 'Some title',
        link: 'http://acme.com',
        description: 'Feed description',
        entries: feedEntries)


    StringWriter writer = new StringWriter()
    SyndFeedOutput output = new SyndFeedOutput()
    output.output(feed,writer)
    writer.close()
    return writer.toString()
}

私の getBody(item) は、アイテムを解析して HTML 形式のテキストを出力するだけです。

render メソッドで ISO-8859-1 に設定したときに、エンコーディングが UTF-8 である理由について手がかりを持っている人はいますか???

ご協力いただきありがとうございます !

4

1 に答える 1

0

「getFeed("rss_2.0")」が別のソースから xml をプルしている可能性はありますか? もしそうなら、何のレンダリングが指定されているのではなく、そのファイルのエンコーディングをレンダリングしている可能性がありますか?

于 2010-06-10T06:08:37.893 に答える