👀 타이틀
- login.jsp
<body>
<form id="frm" method="post" action="./loginok.do">
아이디 : <input type="text" name="mid"><br>
패스워드 : <input type="password" name="mpass"><br>
<button type="submit">로그인</button>
</form>
</body>
- member_repo.java (interface)
@Mapper
public interface member_repo {
//회원가입
public int join(member_dto mdto);
//로그인
//member_dto mdto = void logins(member_dto mdto); => 둘다 써도됨
public List<member_dto> logins(member_dto mdto);
}
- mapper.xml
<select id="logins" resultType="kr.co.sen.member_dto">
select * from member where mid='#{mid}';
</select>
- member_service.java (interface)
package kr.co.sen;
import java.util.List;
public interface member_service {
public int join_member(member_dto mdto);
public List<member_dto> logins(member_dto mdto);
}
- memberServiceImpl.class
package kr.co.sen;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class memberServiceImpl implements member_service{
@Autowired
private member_repo member_repo;
@Override
public int join_member(member_dto mdto) {
int result = member_repo.join(mdto);
return result;
}
@Override
public List<member_dto> logins(member_dto mdto) {
List<member_dto> one = member_repo.logins(mdto);
return one;
}
}
- controller
PrintWriter pw = null;
@Resource(name="member_dto")
member_dto mdto;
@Autowired
private member_service member_service;
@PostMapping("/loginok.do")
public String loginok(@ModelAttribute member_dto mdto, ServletResponse res) {
res.setContentType("text/html;charset=utf-8");
List<member_dto> one = member_service.logins(mdto);
try {
this.pw = res.getWriter();
if(one==null) {
this.pw.write("<script>"
+ "alert('아이디 및 패스워드를 확인하세요.');"
+ "location.href='/login.do';"
+ "</script>");
}else {
if(mdto.getMpass().equals(one.get(0).getMpass())) {
this.pw.write("<script>"
+ "alert('로그인 성공.');"
+ "location.href='/login.do';"
+ "</script>");
}
}
}catch(Exception e) {
System.out.println("DDL 쿼리 오류 발생!!");
}finally {
this.pw.close();
}
return null;
}
에러났는데 몰겠따..
'CLASS > DATABASE' 카테고리의 다른 글
#6-1 / Oracle - data 미러링 , table 제작 상세내역 확인 , trigger (2) | 2024.09.06 |
---|---|
#5-1 / Oracle - Excel 파일 data입력 , 파일로 저장 (3) | 2024.09.05 |
#4-2 / Oracle 실제 테이블에 commit (0) | 2024.09.04 |
#4-1 / Oracle sts 연결 (0) | 2024.09.03 |
#3-2/ Oracle data복구 (0) | 2024.09.03 |