ArticleController.java
package com.linuxidc.controller; import java.io.BufferedReader; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.Date; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import com.alibaba.fastjson.JSON; import com.google.gson.Gson; import com.linuxidc.model.Article; import com.linuxidc.model.News; import com.linuxidc.model.NewsCom; import com.linuxidc.model.User; import com.linuxidc.service.IArticleService; import com.linuxidc.service.INewsComService; import com.linuxidc.service.INewsService; import com.linuxidc.service.IUserService; import net.sf.json.JSONObject; /** * @author linuxidcBaby * 鍒ゆ柇鎵嬫満鍙锋槸鍚﹀凡缁忚娉ㄥ唽 */ @Controller @RequestMapping("/article") public class ArticleController { @Resource private IArticleService articleService; @RequestMapping("/getAllArticle") public String getAll(HttpServletRequest request,Model model){ List<Article> article = this.articleService.getAll(); model.addAttribute("news", JSON.toJSONStringWithDateFormat(article,"yyyy-MM-dd HH:mm")); return "showNews"; } @RequestMapping("/getTitleList") public String getTitleList(HttpServletRequest request,Model model){ String tag= request.getParameter("tag"); List<Article> article = this.articleService.getTitleList(tag); model.addAttribute("news", JSON.toJSONStringWithDateFormat(article,"yyyy-MM-dd HH:mm")); return "showNews"; } }SSM框架的注解配置文件的优劣取舍(2)
内容版权声明:除非注明,否则皆为本站原创文章。