问题描述
- 请问用junit怎样为下面代码编写用例呢?新人求教。最好弄个模板出来。
-
@RequestMapping(value = "/addAdv", produces = "text/html;charset=utf-8") @ResponseBody public String addAdvAction(HttpServletRequest request, HttpServletResponse response) { JSONObj json = new JSONObj(); String advContent = request.getParameter("advContent"); String advImgPath = request.getParameter("advImgPath"); String advTitle = request.getParameter("advTitle"); String advTypeStr = request.getParameter("advType"); try { int advType = Integer.parseInt(advTypeStr); advService.addAdv(advContent, advImgPath, advTitle, advType); json.setCode("success"); json.setMsg("添加成功"); } catch (Exception e) { logger.error(e); e.printStackTrace(); json.setCode("failure"); json.setMsg("添加失败"); } return json.toString(); }
时间: 2024-10-29 02:00:29