@Test public void homePageSubmitMessage() { String message = "unit test message"; String response = controller.sendMessage(message); assertEquals("String message received! Your message: " + message, response); }
@RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "text/plain") public @ResponseBody String sendMessage(@RequestBody String message) { logger.info("String message: " + message); return "String message received! Your message: " + message; }
HomeController { @RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "text/plain") public @ResponseBody String sendMessage(@RequestBody String message) { logger.info("String message: " + message); return "String message received! Your message: " + message; } }
HomeController { @RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "text/plain") public @ResponseBody String sendMessage(@RequestBody String message) { logger.info("String message: " + message); return "String message received! Your message: " + message; }  }
HomeController { @RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "text/plain") public @ResponseBody String sendMessage(@RequestBody String message) { logger.info("String message: " + message); return "String message received! Your message: " + message; }  @RequestMapping(method = RequestMethod.GET) String home(); @RequestMapping(value = "states", method = RequestMethod.GET, produces = "application/json") @ResponseBody List<State> fetchStatesJson(); @RequestMapping(value = "states", method = RequestMethod.GET, produces = "application/xml") @ResponseBody StateList fetchStatesXml(); @RequestMapping(value = "state/{abbreviation}", method = RequestMethod.GET, produces = "application/json") @ResponseBody State fetchStateJson(@PathVariable String abbreviation); @RequestMapping(value = "state/{abbreviation}", method = RequestMethod.GET, produces = "application/xml") @ResponseBody State fetchStateXml(@PathVariable String abbreviation); @RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "text/plain") @ResponseBody String sendMessage(@RequestBody String message); @RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "application/json") @ResponseBody String sendMessageJson(@RequestBody Message message); @RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "application/xml") @ResponseBody String sendMessageXml(@RequestBody Message message); @RequestMapping(value = "sendmessagemap", method = RequestMethod.POST) @ResponseBody String sendMessageMap(@RequestBody LinkedMultiValueMap<String, String> map); }
HomeController { @RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "text/plain") public @ResponseBody String sendMessage(@RequestBody String message) { logger.info("String message: " + message); return "String message received! Your message: " + message; }  @RequestMapping(method = RequestMethod.GET) String home(); @RequestMapping(value = "states", method = RequestMethod.GET, produces = "application/json") @ResponseBody List<State> fetchStatesJson(); @RequestMapping(value = "states", method = RequestMethod.GET, produces = "application/xml") @ResponseBody StateList fetchStatesXml(); @RequestMapping(value = "state/{abbreviation}", method = RequestMethod.GET, produces = "application/json") @ResponseBody State fetchStateJson(@PathVariable String abbreviation); @RequestMapping(value = "state/{abbreviation}", method = RequestMethod.GET, produces = "application/xml") @ResponseBody State fetchStateXml(@PathVariable String abbreviation); @RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "text/plain") @ResponseBody String sendMessage(@RequestBody String message); @RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "application/json") @ResponseBody String sendMessageJson(@RequestBody Message message); @RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "application/xml") @ResponseBody String sendMessageXml(@RequestBody Message message); @RequestMapping(value = "sendmessagemap", method = RequestMethod.POST) @ResponseBody String sendMessageMap(@RequestBody LinkedMultiValueMap<String, String> map);  }