mitocondrr
180
2019-01-16 14:53:52
2
644

전자정부프레임워크 SAMPLE게시판에 로그인, 회원가입 기능 추가


전자정부프레임워크로 샘플 게시판이 있는 웹 프로젝트를 만들고 mybatis설정과 로그인, 회원가입 페이지를 만들어 추가했습니다. 로그인처리단계와 회원등록단계에서 

2019-01-16 14:42:00,978 DEBUG [egovframework.rte.fdl.cmmn.aspect.ExceptionTransfer] execute ExceptionTransfer.transfer 

2019-01-16 14:42:00,980 DEBUG [egovframework.rte.fdl.cmmn.aspect.ExceptionTransfer] RuntimeException case :: RuntimeException 

2019-01-16 14:42:00,981 ERROR [egovframework.example.sample.service.impl.MemberServiceImpl] null

2019-01-16 14:42:00,981 DEBUG [egovframework.rte.fdl.cmmn.exception.manager.DefaultExceptionHandleManager]  DefaultExceptionHandleManager.run() 

2019-01-16 14:42:00,981 DEBUG [egovframework.rte.fdl.cmmn.exception.manager.DefaultExceptionHandleManager] pattern = **service.impl.*, thisPackageName = egovframework.example.sample.service.impl.MemberServiceImpl.joinInsert

2019-01-16 14:42:00,981 DEBUG [egovframework.rte.fdl.cmmn.exception.manager.DefaultExceptionHandleManager] pm.match(pattern, thisPackageName) = true

2019-01-16 14:42:00,981 DEBUG [egovframework.example.cmmn.EgovSampleExcepHndlr]  EgovServiceExceptionHandler run...............

2019-01-16 14:42:00,981 DEBUG [egovframework.rte.fdl.cmmn.exception.manager.DefaultExceptionHandleManager]  DefaultExceptionHandleManager.run() 

2019-01-16 14:42:00,981 DEBUG [egovframework.rte.fdl.cmmn.exception.manager.DefaultExceptionHandleManager] pattern = **service.impl.*, thisPackageName = egovframework.example.sample.service.impl.MemberServiceImpl.joinInsert

2019-01-16 14:42:00,982 DEBUG [egovframework.rte.fdl.cmmn.exception.manager.DefaultExceptionHandleManager] pm.match(pattern, thisPackageName) = true

2019-01-16 14:42:00,982 DEBUG [egovframework.example.cmmn.EgovSampleOthersExcepHndlr]  EgovServiceExceptionHandler run...............


다음과 같은 에러가 계속 발생합니다. 아래는 제가 추가한 것들입니다.


MemberService.java

package egovframework.example.sample.service;

import javax.servlet.http.HttpSession;

import org.springframework.transaction.annotation.Transactional;

import egovframework.example.sample.service.MemberVO;

public interface MemberService {
	
	//로그인 체크
	@Transactional
	public int loginChk(MemberVO vo, HttpSession session) throws Exception;
	
	//로그인 정보
	@Transactional
	public MemberVO viewMember(MemberVO vo) throws Exception;
	
	//회원 로그아웃
	@Transactional
	public void logout(HttpSession session) throws Exception;
	
	//회원등록
	public void joinInsert(MemberVO vo)throws Exception;

}


MemberVO.java

package egovframework.example.sample.service;

public class MemberVO {
	
	//회원아이디
	private String memberId;
	
	//회원비밀번호
	private String memberPw;
		
	//회원명
	private String memberNm;
				
	//회원부서
	private String memberPt;

	public String getMemberId() {
		return memberId;
	}

	public void setMemberId(String memberId) {
		this.memberId = memberId;
	}

	public String getMemberPw() {
		return memberPw;
	}

	public void setMemberPw(String memberPw) {
		this.memberPw = memberPw;
	}

	public String getMemberNm() {
		return memberNm;
	}

	public void setMemberNm(String memberNm) {
		this.memberNm = memberNm;
	}

	public String getMemberPt() {
		return memberPt;
	}

	public void setMemberPt(String memberPt) {
		this.memberPt = memberPt;
	}
	
	@Override
	public String toString() {
		return "MemberVO [memberId=" + memberId + ", memberPw=" + memberPw + ", memberNm=" + memberNm + ", memberPt=" + memberPt + "]";
	}
	
	
}


MemberDAO.java

package egovframework.example.sample.service.impl;

import javax.inject.Inject;
import javax.servlet.http.HttpSession;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import egovframework.example.sample.service.MemberVO;
import egovframework.rte.psl.dataaccess.EgovAbstractDAO;

@Repository("MemberDAO")
public class MemberDAO extends EgovAbstractDAO {
	
	@Inject
	SqlSession sqlSession;
	
	//로그인체크
	public int loginChk(MemberVO vo)  throws Exception{
		int name = sqlSession.selectOne("MemberMapper.loginChk", vo);
		return (name);
	}
	
	//로그인정보
	public MemberVO viewMember(MemberVO vo) throws Exception{
		return sqlSession.selectOne("MemberMapper.viewMember", vo);
	}
	
	//로그아웃
	public void logout(HttpSession session) throws Exception{
		
	}
	
	//회원등록
			public void joinInsert(MemberVO vo) {
				sqlSession.insert("MemberMapper.joinInsert", vo);			
			}
}


MemberMapper.java

package egovframework.example.sample.service.impl;

import javax.inject.Inject;
import javax.servlet.http.HttpSession;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import egovframework.example.sample.service.MemberVO;
import egovframework.rte.psl.dataaccess.EgovAbstractMapper;

@Repository("memberMapper")
public class MemberMapper extends EgovAbstractMapper {
	
	@Inject
	SqlSession sqlSession;
	
	//로그인 체크
		public int loginChk(MemberVO vo) throws Exception{
			return sqlSession.selectOne("MemberMapper.loginChk", vo);
		}
		
		//로그인 정보
		public MemberVO viewMember(MemberVO vo) throws Exception{
			return sqlSession.selectOne("MemberMapper.viewMember", vo);
		}
		
		//로그아웃
		public void logout(HttpSession session) throws Exception{
			
		}
		
		//회원등록
		public void joinInsert(MemberVO vo) {
			sqlSession.insert("MemberMapper.joinInsert", vo);			
		}
	
}


MemberServiceImpl.java

package egovframework.example.sample.service.impl;

import javax.annotation.Resource;



import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Service;

import egovframework.example.sample.service.MemberService;
import egovframework.example.sample.service.MemberVO;
import egovframework.rte.fdl.cmmn.EgovAbstractServiceImpl;
import egovframework.example.sample.service.impl.MemberMapper;



@Service ("memberService")
public class MemberServiceImpl extends EgovAbstractServiceImpl implements MemberService {
	
		  @Resource(name="memberMapper")
			private MemberMapper memberMapper;
		  
	
	//로그인 체크
	public int loginChk(MemberVO vo, HttpSession session) throws Exception{
		int result = memberMapper.loginChk(vo);
		if (result == 1){
			MemberVO vo2 = viewMember(vo);
			session.setAttribute("memberId", vo2.getMemberId());
			session.setAttribute("memberNm", vo2.getMemberNm());
		}
		return result;
	}
	
	
	//로그인 정보
	public MemberVO viewMember(MemberVO vo) throws Exception{
		return memberMapper.viewMember(vo);	
	}
	
	//로그아웃
	public void logout(HttpSession session) throws Exception{
		session.invalidate();
	}


	//회원등록
	public void joinInsert(MemberVO vo) throws Exception {
		memberMapper.joinInsert(vo);		
	}

	
	

}


MemberController.java


package egovframework.example.sample.web;


import egovframework.example.sample.service.MemberService;

import egovframework.example.sample.service.MemberVO;
import egovframework.rte.fdl.property.EgovPropertyService;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


@Controller
public class MemberController {
	
	@Resource(name = "memberService")
	private MemberService memberService;

	@Resource(name = "propertiesService")
	protected EgovPropertyService propertiesService;
	
	//로그인화면
	@RequestMapping(value="/login.do")
	public String login(@ModelAttribute MemberVO vo, HttpSession session)throws Exception{
		return "sample/login";
	}
	
	//로그인체크
	@RequestMapping(value="/loginChk.do")
	public ModelAndView loginChk(@ModelAttribute MemberVO vo, HttpSession session) throws Exception{
		int result = memberService.loginChk(vo, session);
		ModelAndView mav = new ModelAndView();
		if (result == 1) {
			mav.setViewName("sample/home");
			mav.addObject("msg", "success");
		} else {
			mav.setViewName("sample/login");
			mav.addObject("msg", "failure");
		}
		return mav;
	}
	
	//로그아웃
	@RequestMapping(value="/logout.do")
	public ModelAndView logout(HttpSession session) throws Exception{
		memberService.logout(session);
		ModelAndView mav = new ModelAndView();
		mav.setViewName("sample/login");
		mav.addObject("msg", "logout");
		return mav;
	}
	
	//회원가입화면
	@RequestMapping(value="/join.do")
	public String join(@ModelAttribute MemberVO vo, HttpSession session)throws Exception{
		return "sample/join";
	}
	
	//회원등록
	@RequestMapping(value="/joinInsert.do")
	public String joinInsert(@ModelAttribute MemberVO vo)throws Exception{
		memberService.joinInsert(vo);
		return "sample/login.do";
	}

}


Member_SQL.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="MemberMapper">

	<resultMap id="member" type="egovframework.example.sample.service.MemberVO">
		<result property="memberId" column="MEMBERID"/>
		<result property="memberPw" column="MEMBERPW"/>
		<result property="memberNm" column="MEMBERNM"/>
		<result property="memberPt" column="MEMBERPT"/>
	</resultMap>
	
	<select id="loginChk" resultType="Int">
		SELECT count(*)
		FROM MEMBER
		WHERE MEMBERID = '#{memberId}' AND MEMBERPW = #{memberPw}
	</select>
	
	<select id="viewMember" resultType="egovframework.example.sample.service.MemberVO">
		SELECT
			MEMBERNM AS memberNm,
			MEMBERID AS memberId,
			MEMBERPT AS memberPt
		FROM MEMBER
		WHERE MEMBERID = '#{memberId}' AND MEMBERPW = #{memberPw}
	</select>
	
	<insert id="joinInsert">
		INSERT INTO MEMBER
			(MEMBERID, MEMBERPW, MEMBERNM, MEMBERPT)
		VALUES
			('#{memberId}', '#{memberPw}', '#{meemberNm}', '#{memberPt}')
	</insert>
</mapper>


이제 개발을 막 시작해서 여기저기 찾아서 만든거라 지식이 부족합니다ㅠㅜ 

쉬운 답변으로 부탁드려요...

0
0
  • 답변 2

  • 아스키
    10k
    2019-01-16 14:58:38

    2019-01-16 14:42:00,981 ERROR [egovframework.example.sample.service.impl.MemberServiceImpl] null

    ERROR 표시된 곳 디버그 해보세요..

    0
  • mitocondrr
    180
    2019-01-16 16:23:11

    ServiceImpl에 null이 나오는 문제는 해결했는데 쿼리에 이상 있는지 확인 부탁드려요ㅠ 

    mybatis설정이고 oracle db사용중입니다.

    <select id="loginChk" resultType="Int">

    SELECT

    COUNT(*)

    FROM

    MEMBER

    WHERE

    MEMBERID=#{memberId}

    AND MEMBERPW=#{memberPw}

    </select>

    <select id="viewMember" resultType="egovframework.example.sample.service.MemberVO">

    SELECT

    MEMBERNM

    MEMBERID

    FROM 

    MEMBER

    WHERE

    MEMBERID=#{memberId}

    AND MEMBERPW=#{memberPw}

    </select>

    <insert id="joinInsert">

    INSERT INTO MEMBER

       ( MEMBERID

    , MEMBERPW

    , MEMBERNM

    , MEMBERPT )

    VALUES

    ( #{memberId}

    , #{memberPw}

    , #{meemberNm}

    , #{memberPt} )

    </insert>

    0
  • 로그인을 하시면 답변을 등록할 수 있습니다.