@Test public void helloTest() throws Exception { mockMvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.TEXT_HTML)) .andExpect(MockMvcResultMatchers.status().isOk()) .andDo(MockMvcResultHandlers.print()); System.out.println("mockMvc = " + mockMvc.getDispatcherServlet().getEnvironment().toString()); }
@GetMapping("/hello") public String hello(Model model) { model.addAttribute("name", "siyoon"); return "index"; }
MyController { @GetMapping("/hello") public String hello(Model model) { model.addAttribute("name", "siyoon"); return "index"; } }
MyController { @GetMapping("/hello") public String hello(Model model) { model.addAttribute("name", "siyoon"); return "index"; }  }
MyController { @GetMapping("/hello") public String hello(Model model) { model.addAttribute("name", "siyoon"); return "index"; }  @GetMapping("/hello") String hello(Model model); @GetMapping("/hello/{name}") @ResponseBody String helloName(@PathVariable String name); @GetMapping("/hello/{name1}/{name2}") @ResponseBody String helloName(@PathVariable(name = "name1") String name1, @PathVariable(name = "name2") String name2); }
MyController { @GetMapping("/hello") public String hello(Model model) { model.addAttribute("name", "siyoon"); return "index"; }  @GetMapping("/hello") String hello(Model model); @GetMapping("/hello/{name}") @ResponseBody String helloName(@PathVariable String name); @GetMapping("/hello/{name1}/{name2}") @ResponseBody String helloName(@PathVariable(name = "name1") String name1, @PathVariable(name = "name2") String name2);  }