Let's start with creating a simple controller with a logger:
@Controller public class UserController { private Log logger = LogFactory.getLog (UserController.class); }
Let's add the following method to the controller:
@RequestMapping(value = "/create-user", method = RequestMethod.GET) public String showCreateUserPage(ModelMap model) { model.addAttribute("user", new User()); return "user"; }
Important things to note are as follows:
- @RequestMapping(value = "/create-user", method = RequestMethod.GET): We are mapping a /create-user URI. For the first time, we are specifying a Request method using the method attribute. This method will be invoked only for HTTP Get Requests. HTTP Get Requests are ...