我查了下网上发现了一些,但是不知道哪个RSS包好用而且还相对比较小。RSSLibJ倒是小,但是发现已经没人维护了,连网站都访问不到了。
麻烦谁给我介绍个小而强大的Java读取RSS的包。谢谢
麻烦谁给我介绍个小而强大的Java读取RSS的包。谢谢
解决方案 »
- weblogic输入用户和密码就开始报错了
- 求Java面试如何描述自己做的项目?
- 关于Struts
- 我用STRUTS和ORACLE数据库做了一个验证用户名和密码的登录程序,报了下面的错误,是为什么啊,我用的服务器是WEBLOGIC?
- 关于struts2中validation的问题
- TOMCAT怎么总不能启动
- 100分求基于Struts的RBAC权限管理代码
- 百分求助:不安装Tomcat直接拷贝文件在客户的机器上,如何配置,才能使tomcat可以使用呢。
- 关于使用rowset
- 我是应届毕业生,马上又要去参加面试,方向是j2ee的,大哥们给点意见!
- SSH框架,启动tomcat报错
- oracle 表字段合并问题:比较急
RSS 1.0 : 在RSS发展过程中,为使RSS成为一个通用的规范,并进一步标准化。一个联合小组根据W3C新一代的Resource Description Framework (RDF) 对RSS进行了重新定义,发布了RSS 1.0版,并把RSS定义为“RDF Site Summary”。现在RSS 1.0版由W3C联合小组维护。
Atom : Atom是一个项目的名字,主要是开发一个新的博客摘要格式以解决目前RSS存在的问题(混乱的版本号,不是一个真正的开放标准,表示方法的不一致,定义贫乏等等)。
2.如何实现RSSRSS标准虽然混乱,但是其本质都是XML文档。你可以只使用notepad, 按照某个RSS标准, 手写一个xml, 并提供给客户端。现在也有许多开源项目来提供RSS的解决方案。Rome https://rome.dev.java.net/RSSLibJ http://enigmastation.com/rsslibj/RSSLib4J http://devzone.stealthp.org/cms/index.php?page=RSSLib4J使用这些解决方案可以更方便的处理RSS.3.用 Rome 实现 RSS 服务目前Rome最新版本为rome-0.9. 本例是在Struts的Action中实现的RSS服务. 新建一个RssAction
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedOutput;
public class RssAction extends DispatchAction {
private static final String MIME_TYPE = "application/xml; charset=UTF-8";
// Rome中RSS的可选标准
// rss_0.90, rss_0.91, rss_0.92, rss_0.93, rss_0.94, rss_1.0, rss_2.0, atom_0.3
private static final String RSS_TYPE = "rss_2.0";
public ActionForward newsFeed(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
NewsFeedBA newsFeedBA = new NewsFeedBA();
newsFeedBA.doExecute();
outputRssFeed(response, newsFeedBA.getFeed());
return null;
}
public ActionForward blogFeed(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
String uid = request.getParameter("userId");
BlogFeedBA blogFeedBA = new BlogFeedBA();
blogFeedBA.setUserId(uid);
blogFeedBA.doExecute();
outputRssFeed(response, blogFeedBA.getFeed());
return null;
}
//将SyndFeed写入HttpServletResponse
private boolean outputRssFeed(HttpServletResponse response, SyndFeed feed) {
boolean result = false;
feed.setFeedType(RSS_TYPE);
response.setContentType(MIME_TYPE);
SyndFeedOutput output = new SyndFeedOutput();
try {
output.output(feed, response.getWriter());
result = true;
} catch (IOException e) {
e.printStackTrace();
} catch (FeedException e) {
e.printStackTrace();
}
return result;
}
}