Exemplo n.º 1
0
 // 查询销售机会信息
 public ActionForward doList(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   PrintWriter out = response.getWriter();
   System.out.println("查询营销机会信息");
   LazyDynaBean ll = new LazyDynaBean();
   BeanUtils.populate(ll, request.getParameterMap());
   Map paramMap = ll.getMap();
   PageResult pgr = chanceService.findAll(paramMap);
   System.out.println("总共有" + pgr.getRowCount() + "条营销机会信息");
   String pgrstr = JSONSerializer.toJSON(pgr).toString();
   System.out.println(pgrstr);
   out.print(pgrstr);
   out.close();
   return null;
 }
  public String execute() throws Exception {
    Page page = new Page();
    page.setEveryPage(10); // 每页显示10条记录
    page.setCurrentPage(currentPage); // 设置当前页
    PageResult pageResult = subjectService.likeQueryBySubjectTitle(subjectTitle, page);
    List<Subject> subjects = pageResult.getList(); // 获得试题记录
    List<Subject> newSubjects = new ArrayList<Subject>(); // 新的记录
    // 给关键字标红
    for (Subject subject : subjects) {
      String newTitle =
          subject
              .getSubjectTitle()
              .replaceAll(subjectTitle, "<font color='red'>" + subjectTitle + "</font>");
      subject.setSubjectTitle(newTitle);
      newSubjects.add(subject);
    }

    page = pageResult.getPage(); // 获得分页信息
    HttpServletRequest request = ServletActionContext.getRequest();
    request.setAttribute("subjects", newSubjects);
    request.setAttribute("page", page);
    return SUCCESS;
  }