Springmvc-rss-feed
提供:Dev Guides
Spring MVC-RSSフィードの生成の例
次の例は、Spring Web MVCフレームワークを使用してRSSフィードを生成する方法を示しています。 まず、動作するEclipse IDEを用意し、Spring Web Frameworkを使用して動的フォームベースのWebアプリケーションを開発するための次の手順を検討します。
Step | Description |
---|---|
1 | Create a project with the name TestWeb under a package com.finddevguides as explained in the Spring MVC - Hello World chapter. |
2 | Create Java classes RSSMessage, RSSFeedViewer and RSSController under the com.finddevguides package. |
3 | Download the Rome library Rome and its dependencies rome-utils, jdom and slf4j from the same maven repository page. Put them in your CLASSPATH. |
4 | Create a properties file messages.properties under the SRC folder. |
5 | The final step is to create the content of the source and configuration files and export the application as explained below. |
RSSMessage.java
RSSFeedViewer.java
RSSController.java
TestWeb-servlet.xml
ここでは、 AbstractRssFeedView を拡張し、そのメソッドをオーバーライドするRSSフィードPOJO RSSMessageとRSSメッセージビューアーを作成しました。 RSSControllerで、サンプルRSSフィードを生成しました。
ソースファイルと構成ファイルの作成が完了したら、アプリケーションをエクスポートします。 アプリケーションを右クリックし、[エクスポート]→[WARファイル]オプションを使用して、 TestWeb.war ファイルをTomcatのwebappsフォルダーに保存します。
次に、Tomcatサーバーを起動し、標準ブラウザーを使用してwebappsフォルダーから他のWebページにアクセスできることを確認します。 URLを試してください- http://localhost:8080/TestWeb/rssfeed すると、次の画面が表示されます。