To do list
* 회원가입 Controller
* User 클래스 생성
* 사용자 아이디
* 비밀번호
* 이메일
* 이름
* 회원가입, 입력 폼
* /users/form => /users/form.jsp
*
--
class UserController
package com.java.web;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.java.dao.users.UserDao;
import com.java.dto.User;
@Controller
@RequestMapping("/users")
public class UserController {
private static final Logger logger=LoggerFactory.getLogger(UserController.class);
@Autowired
private UserDao userDao;
@RequestMapping("/form")
public String form(Model model){
logger.debug("User : {} " , "test");
model.addAttribute("user" , new User());
return "users/form";
}
@RequestMapping(value="", method=RequestMethod.POST)
public String create(User user){
logger.debug("User : {} " , user);
userDao.create(user);
logger.debug("Database : {} " , userDao.findById(user.getUserId()));
return "users/form";
}
}
form.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="../include/header.jspf" %>
</head>
<body>
<%@ include file="../include/navigation.jspf" %>
<div class="container" id="main">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default content-main">
<form:form name="question" method="post" action="/users" modelAttribute="user">
<div class="form-group">
<label for="userId">사용자 아이디</label>
<!-- <input class="form-control" id="userId" name="userId" placeholder="User ID"> -->
<form:input path="userId" cssClass="form-control" />
</div>
<div class="form-group">
<label for="password">비밀번호</label>
<!-- <input type="password" class="form-control" id="password" name="password" placeholder="Password"> -->
<form:password path="password" cssClass="form-control"/>
</div>
<div class="form-group">
<label for="name">이름</label>
<!-- <input class="form-control" id="name" name="name" placeholder="Name"> -->
<form:input path="name" cssClass="form-control"/>
</div>
<div class="form-group">
<label for="email">이메일</label>
<!-- <input type="email" class="form-control" id="email" name="email" placeholder="Email"> -->
<form:input path="email" cssClass="form-control"/>
</div>
<button type="submit" class="btn btn-success clearfix pull-right">회원가입</button>
<div class="clearfix" />
</form:form>
</div>
</div>
</div>
<%@ include file="../include/footer.jspf" %>
</body>
</html>
댓글 ( 4)
댓글 남기기