当我进行junit测试时,我会像这样测试Spring MVC控制器:
request.setRequestURI("/projects/"+idProject+"/modify");
ModelAndView mv = handlerAdapter.handle(request, response, controller);
控制器测试的条件是:
@RequestMapping(value = "{id}/modify")
public String content(ModelMap model, @PathVariable("id") Project object) {
但我不知道如何获取像这样定义的请求处理程序的ResponseBody
响应:
@RequestMapping("/management/search")
public @ResponseBody ArrayList<SearchData> search(@RequestParam("q")) {
....
....
ArrayList<SearchData> datas = ....;
return datas;
}