1:Java Rss開源組件包很多,
如RSSLibJ、RSSLib4J、RSS Reader、FaceRSS等等,
本文使用rssutils.jar,Sun網站有提供下載 。
2:用Myeclipse建WebProject,Jar 放入lib中,tld放入WEB-INF下
3:web.xml
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<!
DOCTYPE
web-app
PUBLIC
"-//Sun Microsystems,
Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"
>
<
web-app
>
<
taglib
>
<
taglib-uri
>
/WEB-INF/rssutils.tld
</
taglib-uri
>
<
taglib-location
>
/WEB-INF/rssutils.tld
</
taglib-location
>
</
taglib
>
</
web-app
>
4:index
.jsp
以CSDN為例,去網站找到Rss xml http://dev.csdn.net/rss/2.xml
<%@
page
language
=
"java"
import
=
"java.util.*"
pageEncoding
=
"BIG5"
%>
<%@
taglib
uri
=
"/WEB-INF/rssutils.tld"
prefix
=
"rss"
%>
<
html
>
</
head
>
<
body
>
<
rss:feed
url
=
"http://dev.csdn.net/rss/2.xml"
feedId
=
"csdn"
/>
<
b
>
Image:
</
b
>
<
rss:channelImage
feedId
=
"csdn"
/>
<
br
>
<
b
>
Title:
</
b
>
<
rss:channelTitle
feedId
=
"csdn"
/>
<
br
>
<
b
>
Link:
</
b
>
<
rss:channelLink
feedId
=
"csdn"
asLink
=
"true"
/>
<
br
>
<
b
>
Description:
</
b
>
<
rss:channelDescription
feedId
=
"csdn"
/>
<
br
>
<
ul
>
<
rss:forEachItem
feedId
=
"csdn"
>
<
li
>
<
rss:itemDescription
feedId
=
"csdn"
/>
</
rss:forEachItem
>
</
ul
>
</
body
>
</
html
>
5:部署、訪問 OK.