91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Spring MVC Controller

發布時間:2020-07-25 02:03:45 來源:網絡 閱讀:169 作者:zjy1002261870 欄目:編程語言

@Controller@RequestMapping("/articlecontent")
br/>@RequestMapping("/articlecontent")

@Autowired
private TestService testService;

@Autowired
private ArticleContentService articleContentService;

private Logger logger=LoggerFactory.getLogger(ArticleContentController.class);

@RequestMapping(value="/articlecontentadd",method=RequestMethod.GET)
public String articleContentAdd(Model model) {
    model.addAttribute("appExtStr", testService.getAppExtStr());
    return "articlecontent/articlecontentadd";
}

@RequestMapping(value="/articlecontentdetail",method=RequestMethod.POST)
public void articleContentDetail(Model model,@RequestBody Map<String, Object> map, HttpServletRequest request,  HttpServletResponse response) {
    Map<String,Object> result = new HashMap<String,Object>();
    Map<String,Object> articleMap =articleContentService.getArticleContent(map).get(0);
    result.putAll(articleMap);
    MvcHelper.WriteResponseInfo(response,result, request.getCharacterEncoding());
}

@RequestMapping(value="/articlecontentadds",method=RequestMethod.POST)
public void articleContentAdds(Model model,@RequestBody Map<String, Object> map, HttpServletRequest request,  HttpServletResponse response) {
    Map<String,Object> result = new HashMap<String,Object>();
    map.put("Creater", "zhoujun");
    int number =articleContentService.insertArticleContent(map);
    if(number > 0) {
        result.put("rtnCnt", "1");
    }else {
        result.put("rtnCnt", "0");
    }
    MvcHelper.WriteResponseInfo(response,result, request.getCharacterEncoding());
}

@RequestMapping(value="/articlecontentlist",method=RequestMethod.POST)
public void articleContentList(Model model,@RequestBody Map<String, Object> map, HttpServletRequest request,  HttpServletResponse response) {
    Map<String,Object> result = new HashMap<String,Object>();
    Map<String, Object> pMap = MvcHelper.getPagerParams(map);
    int totalCnt =articleContentService.getArticleContentListCnt(pMap);
    int totalPage = MvcHelper.getTotalPage(pMap, totalCnt);
    result.put("listMap", articleContentService.getArticleContentList(pMap));
    result.put("totalCnt", totalCnt);
    result.put("totalPage", totalPage);
    MvcHelper.WriteResponseInfo(response,result, request.getCharacterEncoding());
}

}
public class MvcHelper {

public static void WriteResponseInfo(HttpServletResponse response,Object dataObj,String characterEncoding){
    ObjectMapper jacksonObjectMapper = new ObjectMapper();
       String jsonFormatMapResultString = null;
    try {
        jsonFormatMapResultString = jacksonObjectMapper.writeValueAsString(dataObj);
    } catch (JsonProcessingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
       //response.setContentType(request.getContentType());
       response.setCharacterEncoding(characterEncoding);
       try {
        response.getWriter().print(jsonFormatMapResultString);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

public static Map<String, Object> getPagerParams(Map<String, Object> map){
    int pageIndex =Integer.valueOf(String.valueOf(map.getOrDefault("PageIndex", "1")));
    int pageSize = Integer.valueOf(String.valueOf(map.getOrDefault("PageSize", "10")));
    int firstRowIndex = (pageIndex - 1) *pageSize + 1;
    int lastRowIndex = pageIndex * pageSize;
    map.put("firstRowIndex", firstRowIndex);
    map.put("lastRowIndex", lastRowIndex);
    return map;
}

public static int getTotalPage(Map<String, Object> map,int totalCnt) {
    int totalPage = 0;
    int pageSize = Integer.valueOf(String.valueOf(map.getOrDefault("PageSize", "10")));
    // this.TotalCnt % this.PageSize == 0 ? this.TotalCnt / this.PageSize : Math.ceil(this.TotalCnt / this.PageSize) ;
    totalPage = totalCnt % pageSize == 0 ? totalCnt/pageSize : (int)Math.ceil((double)totalCnt/pageSize);
    return totalPage;
}

}

向AI問一下細節
推薦閱讀:
  1. Spring mvc 配置
  2. spring ?MVC

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

滦平县| 安庆市| 昌平区| 浑源县| 中山市| 广安市| 怀化市| 海林市| 科技| 涿州市| 屏东市| 定结县| 犍为县| 上杭县| 军事| 定远县| 边坝县| 铜鼓县| 中西区| 睢宁县| 南溪县| 弥勒县| 大名县| 林甸县| 溧阳市| 黎川县| 绥滨县| 沂南县| 克山县| 东光县| 德钦县| 梓潼县| 舟山市| 根河市| 石柱| 罗平县| 潮安县| 凉城县| 深圳市| 常山县| 贵德县|