十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專業(yè)推廣+無(wú)憂售后,網(wǎng)站問(wèn)題一站解決
@Controller@RequestMapping("/articlecontent")
br/>@RequestMapping("/articlecontent")
站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到陸河網(wǎng)站設(shè)計(jì)與陸河網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、國(guó)際域名空間、網(wǎng)頁(yè)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋陸河地區(qū)。
@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 map, HttpServletRequest request, HttpServletResponse response) {
Map result = new HashMap();
Map 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 map, HttpServletRequest request, HttpServletResponse response) {
Map result = new HashMap();
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 map, HttpServletRequest request, HttpServletResponse response) {
Map result = new HashMap();
Map 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 getPagerParams(Map 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 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;
}
}