Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Kontroler
- @RequestMapping(value="/register", method=RequestMethod.GET)
- public String register(Model model) {
- model.addAttribute("userForm", new User());
- return "register";
- }
- @RequestMapping(value="/success-register", method=RequestMethod.POST)
- public String successRegister(Model model, @ModelAttribute("userForm") User user, BindingResult bindingResult) {
- User newUser = new User();
- newUser.setLogin(user.getLogin());
- newUser.setPassword(user.getPassword());
- UserServiceImpl us = new UserServiceImpl();
- us.storeUser(newUser);
- logger.info("Login: " + user.getLogin());
- logger.info("Pass: " + user.getPassword());
- return "success-register";
- }
- //jsp
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
- <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <title>Welcome page!</title>
- </head>
- <body>
- <div align="center">
- <form:form action="success-register" method="post" commandName="userForm">
- <table border="0">
- <tr>
- <td colspan="2" align="center"><h2>Spring MVC Form Demo - Registration</h2></td>
- </tr>
- <tr>
- <td>User Name:</td>
- <td><form:input path="login" /></td>
- </tr>
- <tr>
- <td>Password:</td>
- <td><form:password path="password" /></td>
- </tr>
- <tr>
- <td colspan="2" align="center"><input type="submit" value="Register" /></td>
- </tr>
- </table>
- </form:form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement