@Test public void testhandle42() throws IOException { RestTemplate restTemplate = new RestTemplate(); byte[] response = restTemplate.postForObject( "http: Resource outFile = new FileSystemResource("d:/image_copy.jpg"); FileCopyUtils.copy(response, outFile.getFile()); }
@ResponseBody @RequestMapping(value = "/handle42/{imageId}") public byte[] handle42(@PathVariable("imageId") String imageId) throws IOException { System.out.println("load image of " + imageId); Resource res = new ClassPathResource("/image.jpg"); byte[] fileData = FileCopyUtils.copyToByteArray(res.getInputStream()); return fileData; }
UserController { @ResponseBody @RequestMapping(value = "/handle42/{imageId}") public byte[] handle42(@PathVariable("imageId") String imageId) throws IOException { System.out.println("load image of " + imageId); Resource res = new ClassPathResource("/image.jpg"); byte[] fileData = FileCopyUtils.copyToByteArray(res.getInputStream()); return fileData; } }
UserController { @ResponseBody @RequestMapping(value = "/handle42/{imageId}") public byte[] handle42(@PathVariable("imageId") String imageId) throws IOException { System.out.println("load image of " + imageId); Resource res = new ClassPathResource("/image.jpg"); byte[] fileData = FileCopyUtils.copyToByteArray(res.getInputStream()); return fileData; }  }
UserController { @ResponseBody @RequestMapping(value = "/handle42/{imageId}") public byte[] handle42(@PathVariable("imageId") String imageId) throws IOException { System.out.println("load image of " + imageId); Resource res = new ClassPathResource("/image.jpg"); byte[] fileData = FileCopyUtils.copyToByteArray(res.getInputStream()); return fileData; }  @RequestMapping(method = RequestMethod.POST) ModelAndView createUser(User user); @RequestMapping(value = "/register", method = RequestMethod.GET, params = "!myParam") String register(@ModelAttribute("user") User user); @RequestMapping(value = "/delete", method = RequestMethod.POST, params = "userId") String test1(@RequestParam("userId") String userId); @RequestMapping(value = "/show", headers = "content-type=text/*") String test2(@RequestParam("userId") String userId); @RequestMapping(value = "/param") String handleRequestParam(@RequestParam("userName") String userName,
                                     @RequestParam("password") String password,
                                     @RequestParam("realName") String realName); @RequestMapping(value = "/cookie") ModelAndView handleCookie(@CookieValue("JSESSIONID") String sessionId,
                                     @RequestHeader("Accept-Language") String accpetLanguage); @RequestMapping(value = "/user") String handleUser(User user); @RequestMapping(value = "/request") String handleRequest(HttpServletRequest request); @RequestMapping(value = "/requiredParam") String handleRequiredParam(
            @RequestParam(value = "userName", required = false) String userName,
            @RequestParam("age") int age); @RequestMapping(value = "/requiredCookie") String handleRequiredCookie(
            @CookieValue(value = "sessionId", required = false) String sessionId,
            @RequestParam("age") int age); @RequestMapping(value = "/header") String handleHeader(@RequestHeader("Accept-Encoding") String encoding,
                               @RequestHeader("Keep-Alive") long keepAlive); @RequestMapping(value = "/cascade") String handleCascade(User user); @RequestMapping(value = "/servlet1") void handleServlet1(HttpServletRequest request,
                               HttpServletResponse response); @RequestMapping(value = "/servlet2") ModelAndView handleServlet2(HttpServletRequest request); @RequestMapping(value = "/servlet3") String handleServlet3(HttpSession session); @RequestMapping(value = "/success") String success(); @RequestMapping(value = "/fail") String fail(); @RequestMapping(value = "/servlet4") String handleServlet4(HttpServletRequest request,
                                 @RequestParam("userName") String userName); @RequestMapping(value = "/servlet5") String handleServlet5(WebRequest request); @RequestMapping(value = "/handle31") void handle31(OutputStream os); @RequestMapping(value = "/handle41") String handle41(@RequestBody String body); @ResponseBody @RequestMapping(value = "/handle42/{imageId}") byte[] handle42(@PathVariable("imageId") String imageId); @RequestMapping(value = "/handle43") String handle43(HttpEntity<String> requestEntity); @RequestMapping(value = "/handle44/{imageId}") ResponseEntity<byte[]> handle44(
            @PathVariable("imageId") String imageId); @RequestMapping(value = "/handle51", method = RequestMethod.POST) ResponseEntity<User> handle51(HttpEntity<User> requestEntity); @RequestMapping(value = "/model1") String handleModel1(@ModelAttribute("user") User user); @RequestMapping(value = "/model2") String handleModel2(@ModelAttribute("user") User user); @RequestMapping(value = "/model3") String handleModel3(ModelMap modelMap); @ModelAttribute("user") User getUser(); @ModelAttribute("user1") User getUser1(); @ModelAttribute("user2") User getUser2(); @ModelAttribute("dept") Dept getDept(); @RequestMapping(value = "/model4") String handleModel4(@ModelAttribute("user") User user); @RequestMapping(value = "/model5") String handleModel4(ModelMap modelMap, SessionStatus sessionStatus); @RequestMapping(value = "/handle81") String handle81(@RequestParam("user") User user, ModelMap modelMap); @RequestMapping(value = "/register2") String register2(User user); @RequestMapping(value = "/handle82") String handle82(User user); @RequestMapping(value = "/register3") String register3(); @RequestMapping(value = "/register4") String register4(); @RequestMapping(value = "/valid1") String handleValid(@Valid @ModelAttribute("user") User user,
                              BindingResult bindingResult, ModelMap mm); @RequestMapping(value = "/valid2") String handleValid2(@ModelAttribute("user") User user,
                               BindingResult bindingResult); @RequestMapping(value = "/welcome") String handle100(); @RequestMapping(value = "/showUserList") String showUserList(ModelMap mm); @RequestMapping(value = "/showUserListByFtl") String showUserListInFtl(ModelMap mm); @RequestMapping(value = "/showUserListByXls") String showUserListInExcel(ModelMap mm); @RequestMapping(value = "/showUserListByPdf") String showUserListInPdf(ModelMap mm); @RequestMapping(value = "/showUserListByXml") String showUserListInXml(ModelMap mm); @RequestMapping(value = "/showUserListByJson") String showUserListInJson(ModelMap mm); @RequestMapping(value = "/showUserListByJson1") String showUserListInJson1(ModelMap mm); @RequestMapping(value = "/showUserListByI18n") String showUserListInI18n(ModelMap mm); @RequestMapping(value = "/showUserListMix") String showUserListMix(ModelMap mm); @RequestMapping(value = "/uploadPage") String updatePage(); @RequestMapping(value = "/upload") String updateThumb(@RequestParam("name") String name,
                              @RequestParam("file") MultipartFile file); @RequestMapping(value = "/throwException") String throwException(); @ExceptionHandler(RuntimeException.class) String handleException(RuntimeException re, HttpServletRequest request); @RequestMapping(value = "/notFound") String notFound(); @ResponseStatus(HttpStatus.NOT_FOUND) String notFound(HttpServletRequest request); @InitBinder void initBinder(WebDataBinder binder); }
UserController { @ResponseBody @RequestMapping(value = "/handle42/{imageId}") public byte[] handle42(@PathVariable("imageId") String imageId) throws IOException { System.out.println("load image of " + imageId); Resource res = new ClassPathResource("/image.jpg"); byte[] fileData = FileCopyUtils.copyToByteArray(res.getInputStream()); return fileData; }  @RequestMapping(method = RequestMethod.POST) ModelAndView createUser(User user); @RequestMapping(value = "/register", method = RequestMethod.GET, params = "!myParam") String register(@ModelAttribute("user") User user); @RequestMapping(value = "/delete", method = RequestMethod.POST, params = "userId") String test1(@RequestParam("userId") String userId); @RequestMapping(value = "/show", headers = "content-type=text/*") String test2(@RequestParam("userId") String userId); @RequestMapping(value = "/param") String handleRequestParam(@RequestParam("userName") String userName,
                                     @RequestParam("password") String password,
                                     @RequestParam("realName") String realName); @RequestMapping(value = "/cookie") ModelAndView handleCookie(@CookieValue("JSESSIONID") String sessionId,
                                     @RequestHeader("Accept-Language") String accpetLanguage); @RequestMapping(value = "/user") String handleUser(User user); @RequestMapping(value = "/request") String handleRequest(HttpServletRequest request); @RequestMapping(value = "/requiredParam") String handleRequiredParam(
            @RequestParam(value = "userName", required = false) String userName,
            @RequestParam("age") int age); @RequestMapping(value = "/requiredCookie") String handleRequiredCookie(
            @CookieValue(value = "sessionId", required = false) String sessionId,
            @RequestParam("age") int age); @RequestMapping(value = "/header") String handleHeader(@RequestHeader("Accept-Encoding") String encoding,
                               @RequestHeader("Keep-Alive") long keepAlive); @RequestMapping(value = "/cascade") String handleCascade(User user); @RequestMapping(value = "/servlet1") void handleServlet1(HttpServletRequest request,
                               HttpServletResponse response); @RequestMapping(value = "/servlet2") ModelAndView handleServlet2(HttpServletRequest request); @RequestMapping(value = "/servlet3") String handleServlet3(HttpSession session); @RequestMapping(value = "/success") String success(); @RequestMapping(value = "/fail") String fail(); @RequestMapping(value = "/servlet4") String handleServlet4(HttpServletRequest request,
                                 @RequestParam("userName") String userName); @RequestMapping(value = "/servlet5") String handleServlet5(WebRequest request); @RequestMapping(value = "/handle31") void handle31(OutputStream os); @RequestMapping(value = "/handle41") String handle41(@RequestBody String body); @ResponseBody @RequestMapping(value = "/handle42/{imageId}") byte[] handle42(@PathVariable("imageId") String imageId); @RequestMapping(value = "/handle43") String handle43(HttpEntity<String> requestEntity); @RequestMapping(value = "/handle44/{imageId}") ResponseEntity<byte[]> handle44(
            @PathVariable("imageId") String imageId); @RequestMapping(value = "/handle51", method = RequestMethod.POST) ResponseEntity<User> handle51(HttpEntity<User> requestEntity); @RequestMapping(value = "/model1") String handleModel1(@ModelAttribute("user") User user); @RequestMapping(value = "/model2") String handleModel2(@ModelAttribute("user") User user); @RequestMapping(value = "/model3") String handleModel3(ModelMap modelMap); @ModelAttribute("user") User getUser(); @ModelAttribute("user1") User getUser1(); @ModelAttribute("user2") User getUser2(); @ModelAttribute("dept") Dept getDept(); @RequestMapping(value = "/model4") String handleModel4(@ModelAttribute("user") User user); @RequestMapping(value = "/model5") String handleModel4(ModelMap modelMap, SessionStatus sessionStatus); @RequestMapping(value = "/handle81") String handle81(@RequestParam("user") User user, ModelMap modelMap); @RequestMapping(value = "/register2") String register2(User user); @RequestMapping(value = "/handle82") String handle82(User user); @RequestMapping(value = "/register3") String register3(); @RequestMapping(value = "/register4") String register4(); @RequestMapping(value = "/valid1") String handleValid(@Valid @ModelAttribute("user") User user,
                              BindingResult bindingResult, ModelMap mm); @RequestMapping(value = "/valid2") String handleValid2(@ModelAttribute("user") User user,
                               BindingResult bindingResult); @RequestMapping(value = "/welcome") String handle100(); @RequestMapping(value = "/showUserList") String showUserList(ModelMap mm); @RequestMapping(value = "/showUserListByFtl") String showUserListInFtl(ModelMap mm); @RequestMapping(value = "/showUserListByXls") String showUserListInExcel(ModelMap mm); @RequestMapping(value = "/showUserListByPdf") String showUserListInPdf(ModelMap mm); @RequestMapping(value = "/showUserListByXml") String showUserListInXml(ModelMap mm); @RequestMapping(value = "/showUserListByJson") String showUserListInJson(ModelMap mm); @RequestMapping(value = "/showUserListByJson1") String showUserListInJson1(ModelMap mm); @RequestMapping(value = "/showUserListByI18n") String showUserListInI18n(ModelMap mm); @RequestMapping(value = "/showUserListMix") String showUserListMix(ModelMap mm); @RequestMapping(value = "/uploadPage") String updatePage(); @RequestMapping(value = "/upload") String updateThumb(@RequestParam("name") String name,
                              @RequestParam("file") MultipartFile file); @RequestMapping(value = "/throwException") String throwException(); @ExceptionHandler(RuntimeException.class) String handleException(RuntimeException re, HttpServletRequest request); @RequestMapping(value = "/notFound") String notFound(); @ResponseStatus(HttpStatus.NOT_FOUND) String notFound(HttpServletRequest request); @InitBinder void initBinder(WebDataBinder binder);  }