SpringMVCDemo { @ResponseBody @RequestMapping("/getStudentByName") public String getStudentByName(String name) { Student student = studentService.getStudentByName(name); String message; if (student != null) { message = student.getName() + ":" + student.getCreateDate(); } else { message = "没有查询到数据"; } return "SpringMVCDemo.getPersonByName:" + message; }  @ResponseBody @RequestMapping(value = "/getNameByParam", method = RequestMethod.GET) String getNameByParam(@RequestParam("name") String name); @ResponseBody @RequestMapping("/getNameByModel") String getNameByModel(@ModelAttribute("person") Student person); @ResponseBody @RequestMapping("/getNameByRequest") String getNameByRequest(HttpServletRequest request); @RequestMapping("/studentView") String studentView(ModelMap map); @RequestMapping("/redirect") String redirect(); @ResponseBody @RequestMapping("/getStudentByName") String getStudentByName(String name); @ResponseBody @RequestMapping(value = "/getRequest", method = RequestMethod.GET) String getRequest(); @ResponseBody @RequestMapping(value = "/downloadCsv", method = RequestMethod.GET) String downloadCsv(HttpServletResponse response);  }
@Test public void getStudentByName() { String name = "张三"; System.out.println(springMVCDemo.getStudentByName(name)); }