747
No
Database
package com.slipp.db;
import java.util.HashMap;
import java.util.Map;
import com.slipp.user.User;
public class Database {
private static Map<String, User> users=new HashMap<>();
public static void addUser(User user){
System.out.println("user : " +user.toString());
users.put(user.getUserid(), user);
}
}
User
package com.slipp.user;
public class User {
private String userid;
private String password;
private String name;
private String email;
public User(String userid, String password, String name, String email) {
super();
this.userid = userid;
this.password = password;
this.name = name;
this.email = email;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return "User [userid=" + userid + ", password=" + password + ", name=" + name + ", email=" + email + "]";
}
}
form.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="/commons/_head.jspf" %>
<body>
<%@ include file="/commons/_top.jspf" %>
<div class="container">
<div class="row">
<div class="span12">
<section id="typography">
<div class="page-header">
<h1>회원가입</h1>
</div>
<form class="form-horizontal" action="form_action.jsp" method="post">
<div class="control-group">
<label class="control-label" for="userId">사용자 아이디</label>
<div class="controls">
<input type="text" name="userId" value="" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="password">비밀번호</label>
<div class="controls">
<input type="password" id="password" name="password" placeholder="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="name">이름</label>
<div class="controls">
<input type="text" id="name" name="name" value="" placeholder="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">이메일</label>
<div class="controls">
<input type="text" id="email" name="email" value="" placeholder="">
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-primary">회원가입</button>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
form_action.jsp
<%@page import="com.slipp.db.Database"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.slipp.user.User" %>
<%
String userid=request.getParameter("userId");
String password=request.getParameter("password");
String name=request.getParameter("name");
String email=request.getParameter("email");
User user =new User(userid,password, name, email);
Database.addUser(user);
response.sendRedirect("/");
%>
댓글 ( 4)
댓글 남기기