/** * The doPost method of the servlet. <br> * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=utf-8"); request.setCharacterEncoding("utf-8"); PrintWriter out = response.getWriter(); String result; int userId = 0; try { userId = Integer.parseInt(request.getParameter("userId")); } catch (NumberFormatException e) { DataInfoBean info = DataInfoBean.createErrorDataInfoBean("请求数据不正确"); result = info.object2Json(); DebugUtility.p("result " + result); out.print(result); out.flush(); out.close(); return; } result = ((UserLikePhotoService) AppliationContextUtility.getBean("userLikePhotoService")) .getPhotoCount(userId); DebugUtility.p("result " + result); out.print(result); out.flush(); out.close(); }
public String add(PhoneMessage pm) { phoneMessageDAO.save(pm); DataInfoBean dataInfoBean = DataInfoBean.createSuccessDataInfoBean("添加记录成功", null); return dataInfoBean.object2Json(); }