Example #1
0
 protected void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   SQLHelper sqlHelper = new SQLHelper();
   try {
     // 从news中取出最新添加的News对象
     News news = sqlHelper.queryNearestNews("news", "createtime");
     System.out.println(news.getContent());
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  static String getNewsHtmlForm(String category) {

    String categoryLink = RssContainer.categoryLinkContainer.get(category.toLowerCase());
    StringBuilder sb = new StringBuilder();

    for (News singleNews : NewsServices.getNews(categoryLink)) {
      sb.append(
          String.format(
              templateNews,
              singleNews.getLink(),
              singleNews.getTitle(),
              singleNews.getDescription()));
    }
    return sb.toString();
  }
 public void insertNews(News news) {
   try {
     newsMapper.insert(news);
     session.commit();
   } catch (Exception ignore) {
     logger.error(news.toString());
   }
 }