大环境概述:

java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)

  spring的版本:3.1.0.RELEASE

  spring-mock的版本:1.2.6

  采用Spring 注解mvc

  控制层:

@Controller
@RequestMapping("/case")
public class CaseController {
 @RequestMapping(value = "/list", method = RequestMethod.POST)
 public String list(HttpServletRequest request, HttpServletResponse response) {
  String name = request.getParameter("name");
  request.setAttribute("name", name);
  List<String> result = new ArrayList<String>();
  result.add("result1");
  result.add("result2");
  result.add("result3");
  request.setAttribute("result", result);
  return "case/list";
 }

 @RequestMapping(value = "/listJson", method = RequestMethod.POST)
 @ResponseBody
 public List<String> listJson(HttpServletRequest request, HttpServletResponse response) {
  String name = request.getParameter("name");
  List<String> result = new ArrayList<String>();
  result.add("result1");
  result.add("result2");
  result.add("result3");
  return result;
 }

}