----------------------------------
상담게시판 회원 가입 (아이디 중복 체크)
//memberInsertForm.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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=EUC-KR">
<title>Java 전문 교육센터</title>
<link rel="stylesheet" type="text/css" href="common.css">
<link rel="stylesheet" type="text/css" href="table.css">
<script type="text/javascript" src="consultation.js"></script>
<script type="text/javascript">
function msg() {
}
</script>
</head>
<body onload="msg()">
<div>
<%-- 메인메뉴를 import 구문으로 대체 --%>
<c:import url="mainMenu.jsp"></c:import>
<div>
<h3>[회원가입]</h3>
<form action="memberInsert.action" method="post" id="memberForm">
* 등록된 전화로 통화가 가능한 경우에만 회원 가입이 완료됩니다.<br>
<table cellpadding="5" class="style01 borderTop borderBottom">
<tr>
<td class="tName" width="200px">*아이디<span style="font-size:9pt;">(20자 이내)</span></td>
<td class="bTitle"><input type="text" id="id" name="id"><a href="javascript:idCheck()">[아이디 중복확인]</a><span id="idMsg"></span></td>
</tr>
<tr>
<td class="tName" width="200px">*패스워드<span style="font-size:9pt;">(20자 이내)</span></td>
<td class="bTitle"><input type="password" id="pw" name="pw"><span id="pwMsg"></span></td>
</tr>
<tr>
<td class="tName" width="200px">*이름<span style="font-size:9pt;">(20자 이내)</span></td>
<td class="bTitle"><input type="text" id="name" name="name"><span id="nameMsg"></span></td>
</tr>
<tr>
<td class="tName" width="200px">*이메일<span style="font-size:9pt;">(100자 이내)</span></td>
<td class="bTitle"><input type="text" id="email" name="email" style="width:300px"><span id="emailMsg"></span></td>
</tr>
<tr>
<td class="tName" width="200px">*전화<span style="font-size:9pt;">(30자 이내)</span></td>
<td class="bTitle"><input type="text" id="tel" name="tel" style="width:300px"><span id="telMsg"></span></td>
</tr>
</table>
<br>
<a href="javascript:memberFormSubmit()">[확인]</a>
<span id="submitMsg"></span>
</form>
</div>
</div>
</body>
</html>
//memberStruts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="member" extends="struts-default" namespace="" >
<action name="login"
class="com.test.MemberAction"
method="login">
<result name="error">/login.jsp</result>
<result name="success">/memberInfo.jsp</result>
</action>
<action name="logout"
class="com.test.MemberAction"
method="logout">
<result type="redirectAction">login.action</result>
</action>
<action name="memberInfo"
class="com.test.MemberAction"
method="memberInfo">
<result>/memberInfo.jsp</result>
</action>
<action name="memberInsertForm">
<result>/memberInsertForm.jsp</result>
</action>
<action name="memberIDCheck"
class="com.test.MemberAction"
method="memberIDCheck">
<result>/memberIDCheck.jsp</result>
</action>
</package>
</struts>
//consultation.js -> Ajax 요청 주소만 변경함
function consultInsertSubmit() {
//데이터 검사
//에러 메시지 출력
//데이터 전송
var obj = document.getElementById("consultInsertForm");
var name = document.getElementById("name");
var pw = document.getElementById("pw");
var title = document.getElementById("title");
var nameMsg = document.getElementById("nameMsg");
nameMsg.style.display = "none";
var pwMsg = document.getElementById("pwMsg");
pwMsg.style.display = "none";
var titleMsg = document.getElementById("titleMsg");
titleMsg.style.display = "none";
if (name.value == "" || name.value.length > 20) {
nameMsg.style.display = "inline";
return;
}
if (pw.value == "" || pw.value.length > 20) {
pwMsg.style.display = "inline";
return;
}
if (title.value == "" || title.value.length > 100) {
titleMsg.style.display = "inline";
return;
}
obj.submit();
}
function pwFormSubmit() {
//데이터 검사
//에러 메시지 출력
//데이터 전송
var obj = document.getElementById("pwForm");
var name = document.getElementById("name");
var pw = document.getElementById("pw");
var nameMsg = document.getElementById("nameMsg");
nameMsg.style.display = "none";
var pwMsg = document.getElementById("pwMsg");
pwMsg.style.display = "none";
if (name.value == "" || name.value.length > 20) {
nameMsg.style.display = "inline";
return;
}
if (pw.value == "" || pw.value.length > 20) {
pwMsg.style.display = "inline";
return;
}
obj.submit();
}
function consultModifySubmit(){
var obj = document.getElementById("consultModifyForm");
var title = document.getElementById("title");
var titleMsg = document.getElementById("titleMsg");
titleMsg.style.display="none";
if(title.value=="" || title.value.length>100){
titleMsg.style.display="inline";
return;
}
obj.submit();
}
function consultSearchSubmit() {
//데이터 검사
//에러 메시지 출력
//데이터 전송
var obj = document.getElementById("consultSearchForm");
var svalue = document.getElementById("svalue");
var searchMsg = document.getElementById("searchMsg");
searchMsg.style.display = "none";
if (svalue.value == "") {
searchMsg.style.display = "inline";
return;
}
obj.submit();
}
function loginFormSubmit() {
var obj = document.getElementById("loginForm");
var id = document.getElementById("id");
var pw = document.getElementById("pw");
var idMsg = document.getElementById("idMsg");
idMsg.style.display = "none";
var pwMsg = document.getElementById("pwMsg");
pwMsg.style.display = "none";
if (id.value == "" || id.value.length > 20) {
idMsg.style.display = "inline";
return;
}
if (pw.value == "" || pw.value.length > 20) {
pwMsg.style.display = "inline";
return;
}
obj.submit();
}
//댓글 펼치기, 감추기 호출 함수 추가
function commentDivPanel() {
var commentMsg = document.getElementById("commentMsg");
var commentDiv = document.getElementById("commentDiv");
if (commentMsg.innerHTML == "[댓글 펼치기]") {
commentMsg.innerHTML = "[댓글 감추기]";
commentDiv.style.display = "block";
} else {
commentMsg.innerHTML = "[댓글 펼치기]";
commentDiv.style.display = "none";
}
}
function commentInsertSubmit() {
var commentInsertForm = document.getElementById("commentInsertForm");
//데이터 검사 과정 추가
var title = document.getElementById("title");
var commentErrMsg = document.getElementById("commentErrMsg");
commentErrMsg.style.display="none";
if(title.value=="" || title.value.length>200){
commentErrMsg.style.display="inline";
return;
}
commentInsertForm.submit();
}
function consultMemberInsertSubmit() {
//데이터 검사
//에러 메시지 출력
//데이터 전송
var obj = document.getElementById("consultInsertForm");
var title = document.getElementById("title");
var titleMsg = document.getElementById("titleMsg");
titleMsg.style.display = "none";
if (title.value == "" || title.value.length > 100) {
titleMsg.style.display = "inline";
return;
}
obj.submit();
}
//---------------------------------
//회원 전용 삭제 함수 추가
function consultMemberDelete(sid) {
if (confirm("현재 자료를 삭제하시겠습니까?")) {
window.location.href="consultMemberDelete.action?sid="+sid;
}
}
//---------------------------------
//-------------------------------
//회원 입력 관련 함수 추가
//아이디 중복 검사 확인용 변수 추가
var idCheckClick = false;
var idCheckResult = false;
function idCheck() {
var id = document.getElementById("id");
var idMsg = document.getElementById("idMsg");
idMsg.innerHTML = "";
if (id.value == "" || id.value.length > 20) {
/*
idMsg.style.color = "red";
idMsg.style.fontSize = "small";
idMsg.innerHTML = "1~20자 이내의 아이디를 입력해야 합니다.";
*/
idMsg.innerHTML = "<span style=\"color:red; font-size:10pt;\">1~20자 이내의 아이디를 입력해야 합니다.</span>";
return;
}
//Ajax 요청
ajaxFunc(id.value);
idCheckClick = true;
}
function memberFormSubmit() {
//데이터 검사
var obj = document.getElementById("memberForm");
var id = document.getElementById("id");
var pw = document.getElementById("pw");
var name = document.getElementById("name");
var email = document.getElementById("email");
var tel = document.getElementById("tel");
var idMsg = document.getElementById("idMsg");
idMsg.innerHTML = "";
if (id.value == "" || id.value.length > 20) {
idMsg.innerHTML = "<span style=\"color:red; font-size:10pt;\">1~20자 이내의 아이디를 입력해야 합니다.</span>";
return;
}
var pwMsg = document.getElementById("pwMsg");
pwMsg.style.display = "none";
if (pw.value == "" || pw.value.length > 20) {
pwMsg.style.display = "inline";
return;
}
var nameMsg = document.getElementById("nameMsg");
nameMsg.style.display = "none";
if (name.value == "" || name.value.length > 20) {
nameMsg.style.display = "inline";
return;
}
var emailMsg = document.getElementById("emailMsg");
emailMsg.style.display = "none";
if (email.value == "" || email.value.length > 100) {
emailMsg.style.display = "inline";
return;
}
var telMsg = document.getElementById("telMsg");
telMsg.style.display = "none";
if (tel.value == "" || tel.value.length > 100) {
telMsg.style.display = "inline";
return;
}
var submitMsg = document.getElementById("submitMsg");
submitMsg.innerHTML = "";
//아이디 중복 검사 여부 확인
if (!idCheckClick) {
submitMsg.innerHTML = "<span style=\"color:red; font-size:10pt;\">아이디 중복 검사를 먼저 해야 합니다.</span>";
return;
} else {
if (!idCheckResult) {
submitMsg.innerHTML = "<span style=\"color:red; font-size:10pt;\">사용 불가능한 아이디이므로 다른 아이디를 사용해야 합니다.</span>";
return;
}
}
//데이터 전송
obj.submit();
}
//Ajax 관련 함수
var xmlReq;
function ajaxFunc(id) {
xmlReq = new XMLHttpRequest(); //IE7.0 이상
var url = "memberIDCheck.action";
var postString = "data="+id;
xmlReq.onreadystatechange = callBack;
xmlReq.open("POST", url, true);
xmlReq.setRequestHeader("Content-Type"
, "application/x-www-form-urlencoded; charset=euc-kr");
xmlReq.send(postString);
}
function callBack() {
if (xmlReq.readyState == 4) {
if (xmlReq.status == 200) {
printData();
}
}
}
function printData() {
var result = xmlReq.responseText;
var idMsg = document.getElementById("idMsg");
idMsg.innerHTML = "";
if (result.indexOf("OK") != -1) {
idMsg.innerHTML = "<span style=\"color:blue; font-size:10pt;\">사용 가능한 아이디입니다.</span>";
idCheckResult = true;
} else {
idMsg.innerHTML = "<span style=\"color:red; font-size:10pt;\">사용 불가능한 아이디입니다.</span>";
idCheckResult = false;
}
}
//--------------------------------
function memberPwFormSubmit() {
//데이터 검사
var obj = document.getElementById("memberPwForm");
var pw = document.getElementById("pw");
var newpw = document.getElementById("newpw");
var pwMsg = document.getElementById("pwMsg");
var newpwMsg = document.getElementById("newpwMsg");
pwMsg.style.display = "none";
newpwMsg.style.display = "none";
if (pw.value == "" || pw.value.length > 20) {
pwMsg.style.display = "inline";
return;
}
if (newpw.value == "" || newpw.value.length > 20) {
newpwMsg.style.display = "inline";
return;
}
//데이터 전송
obj.submit();
}
function memberModifyFormSubmit() {
//데이터 검사
var obj = document.getElementById("memberModifyForm");
var pw = document.getElementById("pw");
var name = document.getElementById("name");
var email = document.getElementById("email");
var tel = document.getElementById("tel");
var pwMsg = document.getElementById("pwMsg");
pwMsg.style.display = "none";
if (pw.value == "" || pw.value.length > 20) {
pwMsg.style.display = "inline";
return;
}
var nameMsg = document.getElementById("nameMsg");
nameMsg.style.display = "none";
if (name.value == "" || name.value.length > 20) {
nameMsg.style.display = "inline";
return;
}
var emailMsg = document.getElementById("emailMsg");
emailMsg.style.display = "none";
if (email.value == "" || email.value.length > 100) {
emailMsg.style.display = "inline";
return;
}
var telMsg = document.getElementById("telMsg");
telMsg.style.display = "none";
if (tel.value == "" || tel.value.length > 100) {
telMsg.style.display = "inline";
return;
}
//데이터 전송
obj.submit();
}
//MemberAction.java
package com.test;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import com.util.dao.CommonDAO;
import com.util.dao.CommonDAOImpl;
public class MemberAction extends ActionSupport
implements Preparable, ModelDriven<MemberDTO> {
private static final long serialVersionUID = 1L;
private MemberDTO dto;
@Override
public MemberDTO getModel() {
return dto;
}
@Override
public void prepare() throws Exception {
dto = new MemberDTO();
}
public String login() {
if (dto.getId() == null && dto.getPw() == null) {
return ERROR;
} else {
CommonDAO dao = CommonDAOImpl.getInstance();
int result = dao.getIntValue("member.login", dto);
if (result == 0) {
HttpServletRequest req = ServletActionContext.getRequest();
req.setAttribute("error", "true");
return ERROR;
} else {
Object obj = dao.getReadData("member.searchId", dto);
HttpServletRequest req = ServletActionContext.getRequest();
MemberDTO newdto = (MemberDTO)obj;
HttpSession session = req.getSession();
session.setAttribute("id", newdto.getId());
session.setAttribute("name", newdto.getName());
session.setAttribute("grade", newdto.getGrade());
req.setAttribute("dto", obj);
return SUCCESS;
}
}
}
public String logout() {
HttpServletRequest req = ServletActionContext.getRequest();
HttpSession session = req.getSession();
session.invalidate();
return SUCCESS;
}
public String memberInfo() {
HttpServletRequest req = ServletActionContext.getRequest();
HttpSession session = req.getSession();
String id = (String)session.getAttribute("id");
CommonDAO dao = CommonDAOImpl.getInstance();
dto.setId(id);
Object obj = dao.getReadData("member.searchId", dto);
req.setAttribute("dto", obj);
return SUCCESS;
}
public String memberIDCheck() {
HttpServletRequest req = ServletActionContext.getRequest();
String data = req.getParameter("data");
String result = "OK";
CommonDAO dao = CommonDAOImpl.getInstance();
dto.setId(data);
int returnValue = dao.getIntValue("member.duplicateID", dto);
if (returnValue == 1) {
result = "Cancel";
}
req.setAttribute("result", result);
return SUCCESS;
}
}
//memberIDCheck.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%
String result = (String)request.getAttribute("result");
out.write(result);
%>
--------------------------------------------------
문제) 회원 가입의 나머지 절차는 각자 작성할 것.
//memberStruts.xml -> memberInsert.action 주소 등록
//memberIbatis.xml -> INSERT 쿼리 등록
//MemberAction.java -> memberInsert() 메소드 등록
//memberInsertOK.jsp -> 회원 가입 완료 메시지 페이지 작성
---------------------------------------------------
상담 게시판 회원 명단 (관리자, 직원 전용)
//memberInfo.jsp -> 관리자 전용 [*회원명단] 메뉴 추가
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String[] array = {"관리자", "직원", "학생", "회원가입"};
request.setAttribute("array", array);
%>
<!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=EUC-KR">
<title>Java 전문 교육센터</title>
<link rel="stylesheet" type="text/css" href="common.css">
<link rel="stylesheet" type="text/css" href="table.css">
<script type="text/javascript" src="consultation.js"></script>
<script type="text/javascript">
function msg() {
}
</script>
</head>
<body onload="msg()">
<div>
<%-- 메인메뉴를 import 구문으로 대체 --%>
<c:import url="mainMenu.jsp"></c:import>
<div>
<h3>[회원정보]</h3>
<table cellpadding="5" class="style01 borderTop borderBottom">
<tr>
<td width="150">아이디</td><td class="bTitle">${dto.id}</td>
</tr>
<tr>
<td width="150">이름</td><td class="bTitle">${dto.name}</td>
</tr>
<tr>
<td width="150">이메일</td><td class="bTitle">${dto.email}</td>
</tr>
<tr>
<td width="150">전화번호</td><td class="bTitle">${dto.tel}</td>
</tr>
<tr>
<td width="150">등급</td><td class="bTitle">${array[dto.grade-1]}</td>
</tr>
</table>
</div>
<div>
<br>
<%-- 관리자, 직원 전용 메뉴 출력 부분 --%>
<c:if test="${sessionScope.grade == '1' || sessionScope.grade == '2'}">
<a href="memberList.action">[*회원명단]</a>
</c:if>
<a href="memberPWModifyForm.action">[패스워드변경]</a>
<a href="memberModifyForm.action">[회원정보수정]</a>
<a href="">[회원탈퇴]</a>
</div>
</div>
</body>
</html>
//memberStruts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="member" extends="struts-default" namespace="" >
<action name="login"
class="com.test.MemberAction"
method="login">
<result name="error">/login.jsp</result>
<result name="success">/memberInfo.jsp</result>
</action>
<action name="logout"
class="com.test.MemberAction"
method="logout">
<result type="redirectAction">login.action</result>
</action>
<action name="memberInfo"
class="com.test.MemberAction"
method="memberInfo">
<result>/memberInfo.jsp</result>
</action>
<action name="memberInsertForm">
<result>/memberInsertForm.jsp</result>
</action>
<action name="memberIDCheck"
class="com.test.MemberAction"
method="memberIDCheck">
<result>/memberIDCheck.jsp</result>
</action>
<action name="memberList"
class="com.test.MemberAction"
method="memberList">
<result>/memberList.jsp</result>
</action>
</package>
</struts>
//memberIbatis.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="member">
<typeAlias alias="mdto" type="com.test.MemberDTO"/>
<select id="login"
parameterClass="mdto"
resultClass="Integer">
SELECT COUNT(*) AS count
FROM jmember
WHERE id=#id# AND pw=encrypt(#pw#, #id#)
</select>
<select id="searchId"
parameterClass="mdto"
resultClass="mdto">
SELECT id, name, email, tel
, TO_CHAR(wdate, 'YYYY-MM-DD HH24:MI') AS wdate
, grade
FROM jmember
WHERE id=#id#
</select>
<select id="duplicateID"
parameterClass="mdto"
resultClass="Integer">
SELECT COUNT(*) AS count
FROM jmember
WHERE id=#id#
</select>
<select id="lists"
resultClass="mdto">
SELECT id, name, tel, email, grade
, TO_CHAR(wdate, 'YYYY-MM-DD HH24:MI') AS wdate
FROM jmember
ORDER BY grade ASC, name ASC
</select>
</sqlMap>
//MemberAction.java
package com.test;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import com.util.dao.CommonDAO;
import com.util.dao.CommonDAOImpl;
public class MemberAction extends ActionSupport
implements Preparable, ModelDriven<MemberDTO> {
private static final long serialVersionUID = 1L;
private MemberDTO dto;
@Override
public MemberDTO getModel() {
return dto;
}
@Override
public void prepare() throws Exception {
dto = new MemberDTO();
}
public String login() {
if (dto.getId() == null && dto.getPw() == null) {
return ERROR;
} else {
CommonDAO dao = CommonDAOImpl.getInstance();
int result = dao.getIntValue("member.login", dto);
if (result == 0) {
HttpServletRequest req = ServletActionContext.getRequest();
req.setAttribute("error", "true");
return ERROR;
} else {
Object obj = dao.getReadData("member.searchId", dto);
HttpServletRequest req = ServletActionContext.getRequest();
MemberDTO newdto = (MemberDTO)obj;
HttpSession session = req.getSession();
session.setAttribute("id", newdto.getId());
session.setAttribute("name", newdto.getName());
session.setAttribute("grade", newdto.getGrade());
req.setAttribute("dto", obj);
return SUCCESS;
}
}
}
public String logout() {
HttpServletRequest req = ServletActionContext.getRequest();
HttpSession session = req.getSession();
session.invalidate();
return SUCCESS;
}
public String memberInfo() {
HttpServletRequest req = ServletActionContext.getRequest();
HttpSession session = req.getSession();
String id = (String)session.getAttribute("id");
CommonDAO dao = CommonDAOImpl.getInstance();
dto.setId(id);
Object obj = dao.getReadData("member.searchId", dto);
req.setAttribute("dto", obj);
return SUCCESS;
}
public String memberIDCheck() {
HttpServletRequest req = ServletActionContext.getRequest();
String data = req.getParameter("data");
String result = "OK";
CommonDAO dao = CommonDAOImpl.getInstance();
dto.setId(data);
int returnValue = dao.getIntValue("member.duplicateID", dto);
if (returnValue == 1) {
result = "Cancel";
}
req.setAttribute("result", result);
return SUCCESS;
}
public String memberList() {
CommonDAO dao = CommonDAOImpl.getInstance();
List<Object> arrayList = dao.getListData("member.lists");
HttpServletRequest req = ServletActionContext.getRequest();
req.setAttribute("arrayList", arrayList);
return SUCCESS;
}
}
//memberList.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String[] array = {"관리자", "직원", "학생", "회원가입"};
request.setAttribute("array", array);
%>
<!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=EUC-KR">
<title>Java 전문 교육센터</title>
<link rel="stylesheet" type="text/css" href="common.css">
<link rel="stylesheet" type="text/css" href="table.css">
<script type="text/javascript" src="consultation.js"></script>
<script type="text/javascript">
function memberAdminRemove(url, uid) {
if (confirm("아이디 : "+uid+"\n\n선택한 회원의 정보를 삭제하시겠습니까?")) {
window.location.href=url+"?uid="+uid;
}
}
function memberList(obj) {
window.location.href="memberList.action?grade="+obj.value;
}
//----------------------------
//등급별 출력시 선택한 등급 표시하기 위한 부분 추가
function radioCheck() {
var radios = document.getElementsByName("radioGroup");
radios[0].checked = true;
}
//----------------------------
</script>
</head>
<body onload="radioCheck()">
<div>
<%-- 메인메뉴를 import 구문으로 대체 --%>
<c:import url="mainMenu.jsp"></c:import>
<div>
<h3>[*회원명단]</h3>
<div>
<form>
<input type="radio" name="radioGroup"
checked="checked"
onclick="memberList(this)" value="0">전체
<input type="radio" name="radioGroup"
onclick="memberList(this)" value="1">관리자
<input type="radio" name="radioGroup"
onclick="memberList(this)" value="2">직원
<input type="radio" name="radioGroup"
onclick="memberList(this)" value="3">학생
<input type="radio" name="radioGroup"
onclick="memberList(this)" value="4">회원가입
</form>
<br>
</div>
<table cellpadding="5" class="style01 borderTop">
<tr>
<td class="tName" width="100">아이디</td>
<td class="tName">이름</td>
<td class="tName" width="160">전화</td>
<td class="tName" width="160">이메일</td>
<td class="tName" width="80">등급</td>
<td class="tName" width="120">가입일</td>
<td class="tName" width="80"></td>
</tr>
<c:forEach var="dto" items="${arrayList}">
<tr>
<td class="bDot">${dto.id}</td>
<td class="bDot">${dto.name}</td>
<td class="bDot">${dto.tel}</td>
<td class="bDot">${dto.email}</td>
<td class="bDot">${array[dto.grade-1]}</td>
<td class="bDot">${dto.wdate}</td>
<td class="bDot" style="font-size:9pt;"><a href="">[등급변경]</a><br><a href="">[회원삭제]</a></td>
</tr>
</c:forEach>
</table>
</div>
</div>
</body>
</html>
//요청주소
http://localhost:8090/ConsultationStruts2_20121220/consultList.action
--------------------------------------------------
문제) 상담 게시판에서 회원 명단 출력시 등급별(전체, 관리자, 직원, 학생, 회원가입)로 출력되도록 할 것.
--------------------------------------------------
상담 게시판에서 회원 수정(관리자 전용)
//memberList.jsp -> [회원수정] 메뉴 등록
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String[] array = {"관리자", "직원", "학생", "회원가입"};
request.setAttribute("array", array);
%>
<!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=EUC-KR">
<title>Java 전문 교육센터</title>
<link rel="stylesheet" type="text/css" href="common.css">
<link rel="stylesheet" type="text/css" href="table.css">
<script type="text/javascript" src="consultation.js"></script>
<script type="text/javascript">
function memberAdminRemove(url, uid) {
if (confirm("아이디 : "+uid+"\n\n선택한 회원의 정보를 삭제하시겠습니까?")) {
window.location.href=url+"?uid="+uid;
}
}
function memberList(obj) {
window.location.href="memberList.action?grade="+obj.value;
}
//----------------------------
//등급별 출력시 선택한 등급 표시하기 위한 부분 추가
function radioCheck() {
var radios = document.getElementsByName("radioGroup");
radios[0].checked = true;
}
//----------------------------
</script>
</head>
<body onload="radioCheck()">
<div>
<%-- 메인메뉴를 import 구문으로 대체 --%>
<c:import url="mainMenu.jsp"></c:import>
<div>
<h3>[*회원명단]</h3>
<div>
<form>
<input type="radio" name="radioGroup"
checked="checked"
onclick="memberList(this)" value="0">전체
<input type="radio" name="radioGroup"
onclick="memberList(this)" value="1">관리자
<input type="radio" name="radioGroup"
onclick="memberList(this)" value="2">직원
<input type="radio" name="radioGroup"
onclick="memberList(this)" value="3">학생
<input type="radio" name="radioGroup"
onclick="memberList(this)" value="4">회원가입
</form>
<br>
</div>
<table cellpadding="5" class="style01 borderTop">
<tr>
<td class="tName" width="100">아이디</td>
<td class="tName">이름</td>
<td class="tName" width="160">전화</td>
<td class="tName" width="160">이메일</td>
<td class="tName" width="80">등급</td>
<td class="tName" width="120">가입일</td>
<td class="tName" width="80"></td>
</tr>
<c:forEach var="dto" items="${arrayList}">
<tr>
<td class="bDot">${dto.id}</td>
<td class="bDot">${dto.name}</td>
<td class="bDot">${dto.tel}</td>
<td class="bDot">${dto.email}</td>
<td class="bDot">${array[dto.grade-1]}</td>
<td class="bDot">${dto.wdate}</td>
<td class="bDot" style="font-size:9pt;"><a href="adminUpdateForm.action?id=${dto.id}">[회원수정]</a><br><a href="">[회원삭제]</a></td>
</tr>
</c:forEach>
</table>
</div>
</div>
</body>
</html>
//memberStruts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="member" extends="struts-default" namespace="" >
<action name="login"
class="com.test.MemberAction"
method="login">
<result name="error">/login.jsp</result>
<result name="success">/memberInfo.jsp</result>
</action>
<action name="logout"
class="com.test.MemberAction"
method="logout">
<result type="redirectAction">login.action</result>
</action>
<action name="memberInfo"
class="com.test.MemberAction"
method="memberInfo">
<result>/memberInfo.jsp</result>
</action>
<action name="memberInsertForm">
<result>/memberInsertForm.jsp</result>
</action>
<action name="memberIDCheck"
class="com.test.MemberAction"
method="memberIDCheck">
<result>/memberIDCheck.jsp</result>
</action>
<action name="memberList"
class="com.test.MemberAction"
method="memberList">
<result>/memberList.jsp</result>
</action>
<action name="adminUpdateForm"
class="com.test.MemberAction"
method="adminUpdateForm">
<result name="success">/adminUpdateForm.jsp</result>
<result name="error" type="redirectAction">login.action</result>
</action>
<action name="adminUpdate"
class="com.test.MemberAction"
method="adminUpdate">
<result name="success" type="redirectAction">memberList.action</result>
<result name="error" type="redirectAction">login.action</result>
</action>
</package>
</struts>
//memberIbatis.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="member">
<typeAlias alias="mdto" type="com.test.MemberDTO"/>
<select id="login"
parameterClass="mdto"
resultClass="Integer">
SELECT COUNT(*) AS count
FROM jmember
WHERE id=#id# AND pw=encrypt(#pw#, #id#)
</select>
<select id="searchId"
parameterClass="mdto"
resultClass="mdto">
SELECT id, name, email, tel
, TO_CHAR(wdate, 'YYYY-MM-DD HH24:MI') AS wdate
, grade
FROM jmember
WHERE id=#id#
</select>
<select id="duplicateID"
parameterClass="mdto"
resultClass="Integer">
SELECT COUNT(*) AS count
FROM jmember
WHERE id=#id#
</select>
<select id="lists"
resultClass="mdto">
SELECT id, name, tel, email, grade
, TO_CHAR(wdate, 'YYYY-MM-DD HH24:MI') AS wdate
FROM jmember
ORDER BY grade ASC, name ASC
</select>
<update id="adminModify"
parameterClass="mdto">
UPDATE jmember
SET name=#name#, email=#email#, tel=#tel#, grade=#grade#
WHERE id=#id#
</update>
</sqlMap>
//MemberAction.java
package com.test;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import com.util.dao.CommonDAO;
import com.util.dao.CommonDAOImpl;
public class MemberAction extends ActionSupport
implements Preparable, ModelDriven<MemberDTO> {
private static final long serialVersionUID = 1L;
private MemberDTO dto;
@Override
public MemberDTO getModel() {
return dto;
}
@Override
public void prepare() throws Exception {
dto = new MemberDTO();
}
public String login() {
if (dto.getId() == null && dto.getPw() == null) {
return ERROR;
} else {
CommonDAO dao = CommonDAOImpl.getInstance();
int result = dao.getIntValue("member.login", dto);
if (result == 0) {
HttpServletRequest req = ServletActionContext.getRequest();
req.setAttribute("error", "true");
return ERROR;
} else {
Object obj = dao.getReadData("member.searchId", dto);
HttpServletRequest req = ServletActionContext.getRequest();
MemberDTO newdto = (MemberDTO)obj;
HttpSession session = req.getSession();
session.setAttribute("id", newdto.getId());
session.setAttribute("name", newdto.getName());
session.setAttribute("grade", newdto.getGrade());
req.setAttribute("dto", obj);
return SUCCESS;
}
}
}
public String logout() {
HttpServletRequest req = ServletActionContext.getRequest();
HttpSession session = req.getSession();
session.invalidate();
return SUCCESS;
}
public String memberInfo() {
HttpServletRequest req = ServletActionContext.getRequest();
HttpSession session = req.getSession();
String id = (String)session.getAttribute("id");
CommonDAO dao = CommonDAOImpl.getInstance();
dto.setId(id);
Object obj = dao.getReadData("member.searchId", dto);
req.setAttribute("dto", obj);
return SUCCESS;
}
public String memberIDCheck() {
HttpServletRequest req = ServletActionContext.getRequest();
String data = req.getParameter("data");
String result = "OK";
CommonDAO dao = CommonDAOImpl.getInstance();
dto.setId(data);
int returnValue = dao.getIntValue("member.duplicateID", dto);
if (returnValue == 1) {
result = "Cancel";
}
req.setAttribute("result", result);
return SUCCESS;
}
public String memberList() {
CommonDAO dao = CommonDAOImpl.getInstance();
List<Object> arrayList = dao.getListData("member.lists");
HttpServletRequest req = ServletActionContext.getRequest();
req.setAttribute("arrayList", arrayList);
return SUCCESS;
}
public String adminUpdateForm() {
HttpServletRequest req = ServletActionContext.getRequest();
//관리자만 접근 가능
HttpSession session = req.getSession();
if ((Integer)session.getAttribute("grade") != 1) {
return ERROR;
}
CommonDAO dao = CommonDAOImpl.getInstance();
Object obj = dao.getReadData("member.searchId", dto);
req.setAttribute("dto", obj);
return SUCCESS;
}
public String adminUpdate() {
CommonDAO dao = CommonDAOImpl.getInstance();
try {
dao.updateData("member.adminModify", dto);
} catch (SQLException e) {
System.out.println(e.toString());
}
return SUCCESS;
}
}
//adminUpdateForm.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String[] array = {"관리자", "직원", "학생", "회원가입"};
request.setAttribute("array", array);
%>
<!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=EUC-KR">
<title>Java 전문 교육센터</title>
<link rel="stylesheet" type="text/css" href="common.css">
<link rel="stylesheet" type="text/css" href="table.css">
<script type="text/javascript" src="consultation.js"></script>
<script type="text/javascript">
function adminUpdateFormSubmit() {
var adminUpdateForm = document.getElementById("adminUpdateForm");
adminUpdateForm.submit();
}
function radioCheck(idx) {
var radios = document.getElementsByName("grade");
radios[idx].checked = true;
}
</script>
</head>
<body onload="radioCheck(${dto.grade-1})">
<div>
<%-- 메인메뉴를 import 구문으로 대체 --%>
<c:import url="mainMenu.jsp"></c:import>
<div>
<h3>[*회원명단_회원수정]</h3>
<form action="adminUpdate.action" method="post" id="adminUpdateForm">
<input type="hidden" name="id" value="${dto.id}">
<table cellpadding="5" class="style01 borderTop borderBottom">
<tr>
<td class="tName" width="250px">아이디</td>
<td class="bTitle">${dto.id}</td>
</tr>
<tr>
<td class="tName" width="250px">이름<span style="font-size:9pt;">(20자 이내)</span></td>
<td class="bTitle"><input type="text" id="name" name="name" value="${dto.name}"></td>
</tr>
<tr>
<td class="tName" width="250px">이메일<span style="font-size:9pt;">(100자 이내)</span></td>
<td class="bTitle"><input type="text" id="email" name="email" style="width:300px" value="${dto.email}"></td>
</tr>
<tr>
<td class="tName" width="250px">전화<span style="font-size:9pt;">(30자 이내)</span></td>
<td class="bTitle"><input type="text" id="tel" name="tel" style="width:300px" value="${dto.tel}"></td>
</tr>
<tr>
<td class="tName" width="250px">등급(${array[dto.grade-1]})</td>
<td class="bTitle">
<input type="radio" name="grade" value="1">관리자
<input type="radio" name="grade" value="2">직원
<input type="radio" name="grade" value="3">학생
<input type="radio" name="grade" value="4">회원가입
</td>
</tr>
</table>
<br><br>
<a href="javascript:adminUpdateFormSubmit()">[회원수정]</a>
<a href="memberList.action">[회원명단]</a>
</form>
</div>
</div>
</body>
</html>
//요청주소
http://localhost:8090/ConsultationStruts2_20121220/consultList.action
------------------------------------------------
상담 게시판 패스워드 변경 (사용자)
//memberInfo.jsp -> [패스워드변경] 메뉴에 링크 추가
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String[] array = {"관리자", "직원", "학생", "회원가입"};
request.setAttribute("array", array);
%>
<!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=EUC-KR">
<title>Java 전문 교육센터</title>
<link rel="stylesheet" type="text/css" href="common.css">
<link rel="stylesheet" type="text/css" href="table.css">
<script type="text/javascript" src="consultation.js"></script>
<script type="text/javascript">
function msg() {
}
</script>
</head>
<body onload="msg()">
<div>
<%-- 메인메뉴를 import 구문으로 대체 --%>
<c:import url="mainMenu.jsp"></c:import>
<div>
<h3>[회원정보]</h3>
<table cellpadding="5" class="style01 borderTop borderBottom">
<tr>
<td width="150">아이디</td><td class="bTitle">${dto.id}</td>
</tr>
<tr>
<td width="150">이름</td><td class="bTitle">${dto.name}</td>
</tr>
<tr>
<td width="150">이메일</td><td class="bTitle">${dto.email}</td>
</tr>
<tr>
<td width="150">전화번호</td><td class="bTitle">${dto.tel}</td>
</tr>
<tr>
<td width="150">등급</td><td class="bTitle">${array[dto.grade-1]}</td>
</tr>
</table>
</div>
<div>
<br>
<%-- 관리자, 직원 전용 메뉴 출력 부분 --%>
<c:if test="${sessionScope.grade == '1' || sessionScope.grade == '2'}">
<a href="memberList.action">[*회원명단]</a>
</c:if>
<a href="memberPWModifyForm.action">[패스워드변경]</a>
<a href="memberModifyForm.action">[회원정보수정]</a>
<a href="">[회원탈퇴]</a>
</div>
</div>
</body>
</html>
//memberStruts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="member" extends="struts-default" namespace="" >
<action name="login"
class="com.test.MemberAction"
method="login">
<result name="error">/login.jsp</result>
<result name="success">/memberInfo.jsp</result>
</action>
<action name="logout"
class="com.test.MemberAction"
method="logout">
<result type="redirectAction">login.action</result>
</action>
<action name="memberInfo"
class="com.test.MemberAction"
method="memberInfo">
<result>/memberInfo.jsp</result>
</action>
<action name="memberInsertForm">
<result>/memberInsertForm.jsp</result>
</action>
<action name="memberIDCheck"
class="com.test.MemberAction"
method="memberIDCheck">
<result>/memberIDCheck.jsp</result>
</action>
<action name="memberList"
class="com.test.MemberAction"
method="memberList">
<result>/memberList.jsp</result>
</action>
<action name="adminUpdateForm"
class="com.test.MemberAction"
method="adminUpdateForm">
<result name="success">/adminUpdateForm.jsp</result>
<result name="error" type="redirectAction">login.action</result>
</action>
<action name="adminUpdate"
class="com.test.MemberAction"
method="adminUpdate">
<result name="success" type="redirectAction">memberList.action</result>
<result name="error" type="redirectAction">login.action</result>
</action>
<action name="memberPWModifyForm">
<result>/memberPWModifyForm.jsp</result>
</action>
<action name="memberPWModify"
class="com.test.MemberAction"
method="memberPWModify">
<result name="success" type="redirectAction">memberInfo.action</result>
<result name="error">/memberPWModifyForm.jsp</result>
</action>
</package>
</struts>
//memberPWModifyForm.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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=EUC-KR">
<title>Java 전문 교육센터</title>
<link rel="stylesheet" type="text/css" href="common.css">
<link rel="stylesheet" type="text/css" href="table.css">
<script type="text/javascript" src="consultation.js"></script>
<c:if test="${!empty error}">
<script type="text/javascript">
window.onload = msg;
function msg() {
alert("기존 패스워드가 틀렸습니다.");
}
</script>
</c:if>
</head>
<body>
<div>
<%-- 메인메뉴를 import 구문으로 대체 --%>
<c:import url="mainMenu.jsp"></c:import>
<div>
<h3>[회원정보_패스워드변경]</h3>
<form action="memberPWModify.action" method="post" id="memberPwForm">
<table cellpadding="5" class="style01 borderTop borderBottom">
<tr>
<td class="tName" width="200px">*기존 패스워드<span style="font-size:9pt;">(20자 이내)</span></td>
<td class="bTitle"><input type="password" id="pw" name="pw"><span id="pwMsg" style="color:red; display:none;">1~20자 이내 패스워드 입력해야 합니다.</span></td>
</tr>
<tr>
<td class="tName" width="200px">*새로운 패스워드<span style="font-size:9pt;">(20자 이내)</span></td>
<td class="bTitle"><input type="password" id="newpw" name="newpw"><span id="newpwMsg" style="color:red; display:none;">1~20자 이내 패스워드 입력해야 합니다.</span></td>
</tr>
</table>
<br><br>
<a href="javascript:memberPwFormSubmit()">[패스워드변경]</a>
<a href="memberInfo.action">[회원정보]</a>
</form>
</div>
</div>
</body>
</html>
//memberIbatis.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="member">
<typeAlias alias="mdto" type="com.test.MemberDTO"/>
<select id="login"
parameterClass="mdto"
resultClass="Integer">
SELECT COUNT(*) AS count
FROM jmember
WHERE id=#id# AND pw=encrypt(#pw#, #id#)
</select>
<select id="searchId"
parameterClass="mdto"
resultClass="mdto">
SELECT id, name, email, tel
, TO_CHAR(wdate, 'YYYY-MM-DD HH24:MI') AS wdate
, grade
FROM jmember
WHERE id=#id#
</select>
<select id="duplicateID"
parameterClass="mdto"
resultClass="Integer">
SELECT COUNT(*) AS count
FROM jmember
WHERE id=#id#
</select>
<select id="lists"
resultClass="mdto">
SELECT id, name, tel, email, grade
, TO_CHAR(wdate, 'YYYY-MM-DD HH24:MI') AS wdate
FROM jmember
ORDER BY grade ASC, name ASC
</select>
<update id="adminModify"
parameterClass="mdto">
UPDATE jmember
SET name=#name#, email=#email#, tel=#tel#, grade=#grade#
WHERE id=#id#
</update>
<update id="pwModify"
parameterClass="java.util.Map">
UPDATE jmember
SET pw=encrypt(#newpw#, #id#)
WHERE pw=encrypt(#oldpw#, #id#) AND id=#id#
</update>
</sqlMap>
//MemberAction.java
package com.test;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import com.util.dao.CommonDAO;
import com.util.dao.CommonDAOImpl;
public class MemberAction extends ActionSupport
implements Preparable, ModelDriven<MemberDTO> {
private static final long serialVersionUID = 1L;
private MemberDTO dto;
@Override
public MemberDTO getModel() {
return dto;
}
@Override
public void prepare() throws Exception {
dto = new MemberDTO();
}
public String login() {
if (dto.getId() == null && dto.getPw() == null) {
return ERROR;
} else {
CommonDAO dao = CommonDAOImpl.getInstance();
int result = dao.getIntValue("member.login", dto);
if (result == 0) {
HttpServletRequest req = ServletActionContext.getRequest();
req.setAttribute("error", "true");
return ERROR;
} else {
Object obj = dao.getReadData("member.searchId", dto);
HttpServletRequest req = ServletActionContext.getRequest();
MemberDTO newdto = (MemberDTO)obj;
HttpSession session = req.getSession();
session.setAttribute("id", newdto.getId());
session.setAttribute("name", newdto.getName());
session.setAttribute("grade", newdto.getGrade());
req.setAttribute("dto", obj);
return SUCCESS;
}
}
}
public String logout() {
HttpServletRequest req = ServletActionContext.getRequest();
HttpSession session = req.getSession();
session.invalidate();
return SUCCESS;
}
public String memberInfo() {
HttpServletRequest req = ServletActionContext.getRequest();
HttpSession session = req.getSession();
String id = (String)session.getAttribute("id");
CommonDAO dao = CommonDAOImpl.getInstance();
dto.setId(id);
Object obj = dao.getReadData("member.searchId", dto);
req.setAttribute("dto", obj);
return SUCCESS;
}
public String memberIDCheck() {
HttpServletRequest req = ServletActionContext.getRequest();
String data = req.getParameter("data");
String result = "OK";
CommonDAO dao = CommonDAOImpl.getInstance();
dto.setId(data);
int returnValue = dao.getIntValue("member.duplicateID", dto);
if (returnValue == 1) {
result = "Cancel";
}
req.setAttribute("result", result);
return SUCCESS;
}
public String memberList() {
CommonDAO dao = CommonDAOImpl.getInstance();
List<Object> arrayList = dao.getListData("member.lists");
HttpServletRequest req = ServletActionContext.getRequest();
req.setAttribute("arrayList", arrayList);
return SUCCESS;
}
public String adminUpdateForm() {
HttpServletRequest req = ServletActionContext.getRequest();
//관리자만 접근 가능
HttpSession session = req.getSession();
if ((Integer)session.getAttribute("grade") != 1) {
return ERROR;
}
CommonDAO dao = CommonDAOImpl.getInstance();
Object obj = dao.getReadData("member.searchId", dto);
req.setAttribute("dto", obj);
return SUCCESS;
}
public String adminUpdate() {
CommonDAO dao = CommonDAOImpl.getInstance();
try {
dao.updateData("member.adminModify", dto);
} catch (SQLException e) {
System.out.println(e.toString());
}
return SUCCESS;
}
public String memberPWModify() {
HttpServletRequest req = ServletActionContext.getRequest();
String pw = req.getParameter("pw");
String newpw = req.getParameter("newpw");
HttpSession session = req.getSession();
String id = (String)session.getAttribute("id");
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", id);
map.put("oldpw", pw);
map.put("newpw", newpw);
CommonDAO dao = CommonDAOImpl.getInstance();
try {
int result = dao.updateData("member.pwModify", map);
if (result == 0) {
req.setAttribute("error", "true");
return ERROR;
}
} catch (SQLException e) {
System.out.println(e.toString());
}
return SUCCESS;
}
}
//요청주소
http://localhost:8090/ConsultationStruts2_20121220/consultList.action
'Java > Struts2, iBatis' 카테고리의 다른 글
[20121221] 4일차 (상담게시판 스트럿츠2 버젼) (0) | 2012.12.28 |
---|---|
[20121220] 3일차(상담 게시판 (Struts2, iBatis 버전)) (0) | 2012.12.28 |
[20121218] 2일차 (회원관리+성적처리 프로젝트 (Struts, iBatis 버전)) (0) | 2012.12.18 |
[20121217] 1일차 (Struts2, iBatis Framework, 환경설정) (0) | 2012.12.18 |
WRITTEN BY