728x90
지난 시간 오류가 난 부분 수정
BoardController
@PostMapping("/fwritePro")
public String fwritePro(HttpServletRequest request, MultipartFile file) throws Exception{
//throws Exception => 메소드 호출하는 곳에서 예외처리를 함
System.out.println("BoardController fwritePro()");
//파일 업로드 -> 프로그램 설치
//commons-fileupload, commons-io, javax-annotation 설치
//pom.xml에 코드 작성
//servlet-context.xml에서 프로그램 설정
// 1) 대용량 데이터베이스(오라클) 컬럼에 저장
// 2) 저용량 데이터베이스(Mysql) 서버 폴더에 파일을 업로드하고, 데이터베이스에 파일 이름이 저장 <- 사용할 예정
//name = "file" => MultipartFile file => file 이름이 동일(name="이름"과 MultipartFile 이름 동일해야함)
//업로드 파일 이름이 동일할 경우 => 랜덤문자_파일이름 => 이름 변경
//랜덤 문자 만들기
UUID uuid = UUID.randomUUID();
String filename = uuid.toString() + "_" + file.getOriginalFilename();
System.out.println(filename);
//업로드 원본 파일 file.getBytes() => upload폴더에 복사(파일 업로드)
//FileCopyUtils.copy(원본파일, 복사파일);
System.out.println(uploadPath);
FileCopyUtils.copy(file.getBytes(), new File(uploadPath,filename));
//boardDTO에 파라미터값 저장
//name,subject, content, file
//BoardDTO 객체 생성
BoardDTO boardDTO = new BoardDTO();
boardDTO.setName(request.getParameter("name"));
boardDTO.setSubject(request.getParameter("subject"));
boardDTO.setContent(request.getParameter("content"));
//file 저장
boardDTO.setFile(filename);
System.out.println(boardDTO);
//insertBoard() 메소드 호출
boardService.insertBoard(boardDTO);
return "redirect:/board/flist";
}
글쓰기가 끝나면 글 목록으로 이동
BoardController
@GetMapping("/fcontent")
public String fcontent(BoardDTO boardDTO, Model model) {
System.out.println("BoardController fcontent()");
System.out.println(boardDTO);
//조회수 증가
boardService.updateReadcount(boardDTO);
//boardDTO 리턴할형 = boardService.getBoard(boardDTO) 메소드 호출
boardDTO = boardService.getBoard(boardDTO);
//model 저장
model.addAttribute("boardDTO", boardDTO);
// board/content.jsp 글 목록으로 주소변경없이 이동
return "/center/fcontent";
}
fcontent.jsp
화면에 첨부파일이 보여지게끔
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>center/fcontent.jsp</title>
<link href="${pageContext.request.contextPath}/resources/css/default.css" rel="stylesheet" type="text/css">
<link href="${pageContext.request.contextPath}/resources/css/subpage.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js" type="text/javascript"></script>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/ie7-squish.js" type="text/javascript"></script>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<!--[if IE 6]>
<script src="../script/DD_belatedPNG_0.0.8a.js"></script>
<script>
/* EXAMPLE */
DD_belatedPNG.fix('#wrap');
DD_belatedPNG.fix('#main_img');
</script>
<![endif]-->
</head>
<body>
<div id="wrap">
<!-- 헤더들어가는 곳 -->
<jsp:include page="../inc/top.jsp" />
<!-- 헤더들어가는 곳 -->
<!-- 본문들어가는 곳 -->
<!-- 메인이미지 -->
<div id="sub_img_center"></div>
<!-- 메인이미지 -->
<!-- 왼쪽메뉴 -->
<jsp:include page="../inc/left.jsp" />
<!-- 왼쪽메뉴 -->
<!-- 게시판 -->
<article>
<h1>File Content Notice</h1>
<table id="notice">
<tr><td>글번호</td><td>${boardDTO.num}</td></tr>
<tr><td>글쓴이</td><td>${boardDTO.name}</td></tr>
<tr><td>조회수</td><td>${boardDTO.readcount}</td></tr>
<tr><td>작성일</td><td>${boardDTO.date}</td></tr>
<tr><td>글제목</td><td>${boardDTO.subject}</td></tr>
<tr><td>첨부파일</td><td>${boardDTO.file}</td></tr>
<tr><td>글내용</td><td>${boardDTO.content}</td></tr>
</table>
<div id="table_search">
<c:if test="${! empty sessionScope.id }">
<c:if test="${sessionScope.id eq boardDTO.name }">
<input type="button" value="글수정" class="btn" onclick="location.href='${pageContext.request.contextPath}/board/update?num=${boardDTO.num}'">
<input type="button" value="글삭제" class="btn" onclick="location.href='${pageContext.request.contextPath}/board/delete?num=${boardDTO.num}'">
</c:if>
</c:if>
<input type="button" value="글목록" class="btn" onclick="location.href='${pageContext.request.contextPath}/board/list'">
</div>
<div class="clear"></div>
</article>
<!-- 게시판 -->
<!-- 본문들어가는 곳 -->
<div class="clear"></div>
<!-- 푸터들어가는 곳 -->
<jsp:include page="../inc/bottom.jsp" />
<!-- 푸터들어가는 곳 -->
</div>
</body>
</html>
하이퍼링크를 걸어서 다운로드
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>center/fcontent.jsp</title>
<link href="${pageContext.request.contextPath}/resources/css/default.css" rel="stylesheet" type="text/css">
<link href="${pageContext.request.contextPath}/resources/css/subpage.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js" type="text/javascript"></script>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/ie7-squish.js" type="text/javascript"></script>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<!--[if IE 6]>
<script src="../script/DD_belatedPNG_0.0.8a.js"></script>
<script>
/* EXAMPLE */
DD_belatedPNG.fix('#wrap');
DD_belatedPNG.fix('#main_img');
</script>
<![endif]-->
</head>
<body>
<div id="wrap">
<!-- 헤더들어가는 곳 -->
<jsp:include page="../inc/top.jsp" />
<!-- 헤더들어가는 곳 -->
<!-- 본문들어가는 곳 -->
<!-- 메인이미지 -->
<div id="sub_img_center"></div>
<!-- 메인이미지 -->
<!-- 왼쪽메뉴 -->
<jsp:include page="../inc/left.jsp" />
<!-- 왼쪽메뉴 -->
<!-- 게시판 -->
<article>
<h1>File Content Notice</h1>
<table id="notice">
<tr><td>글번호</td><td>${boardDTO.num}</td></tr>
<tr><td>글쓴이</td><td>${boardDTO.name}</td></tr>
<tr><td>조회수</td><td>${boardDTO.readcount}</td></tr>
<tr><td>작성일</td><td>${boardDTO.date}</td></tr>
<tr><td>글제목</td><td>${boardDTO.subject}</td></tr>
<tr><td>첨부파일</td><td><a href="${pageContext.request.contextPath}/resources/upload/${boardDTO.file}" download>${boardDTO.file}</a></td></tr>
<tr><td>글내용</td><td>${boardDTO.content}</td></tr>
</table>
<div id="table_search">
<c:if test="${! empty sessionScope.id }">
<c:if test="${sessionScope.id eq boardDTO.name }">
<input type="button" value="글수정" class="btn" onclick="location.href='${pageContext.request.contextPath}/board/fupdate?num=${boardDTO.num}'">
<input type="button" value="글삭제" class="btn" onclick="location.href='${pageContext.request.contextPath}/board/fdelete?num=${boardDTO.num}'">
</c:if>
</c:if>
<input type="button" value="글목록" class="btn" onclick="location.href='${pageContext.request.contextPath}/board/flist'">
</div>
<div class="clear"></div>
</article>
<!-- 게시판 -->
<!-- 본문들어가는 곳 -->
<div class="clear"></div>
<!-- 푸터들어가는 곳 -->
<jsp:include page="../inc/bottom.jsp" />
<!-- 푸터들어가는 곳 -->
</div>
</body>
</html>
BoardController
@GetMapping("/fupdate")
public String fupdate(BoardDTO boardDTO, Model model) {
System.out.println("BoardController fupdate()");
boardDTO = boardService.getBoard(boardDTO);
System.out.println(boardDTO);
model.addAttribute("boardDTO",boardDTO);
return "/center/fupdate";
}
fupdate.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>center/fupdate.jsp</title>
<link href="${pageContext.request.contextPath}/resources/css/default.css" rel="stylesheet" type="text/css">
<link href="${pageContext.request.contextPath}/resources/css/subpage.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js" type="text/javascript"></script>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/ie7-squish.js" type="text/javascript"></script>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<!--[if IE 6]>
<script src="../script/DD_belatedPNG_0.0.8a.js"></script>
<script>
/* EXAMPLE */
DD_belatedPNG.fix('#wrap');
DD_belatedPNG.fix('#main_img');
</script>
<![endif]-->
</head>
<body>
<div id="wrap">
<!-- 헤더들어가는 곳 -->
<jsp:include page="../inc/top.jsp" />
<!-- 헤더들어가는 곳 -->
<!-- 본문들어가는 곳 -->
<!-- 메인이미지 -->
<div id="sub_img_center"></div>
<!-- 메인이미지 -->
<!-- 왼쪽메뉴 -->
<jsp:include page="../inc/left.jsp" />
<!-- 왼쪽메뉴 -->
<!-- 게시판 -->
<article>
<h1>File Update Notice</h1>
<!-- 첨부파일 form => post방식을 이용할 것 -->
<form action="${pageContext.request.contextPath}/board/fupdatePro" method="post" enctype="multipart/form-data">
<input type="hidden" name="num" value="${boardDTO.num }">
<table id="notice">
<!-- 글쓴이 : 로그인 값 -->
<tr><td>글쓴이</td><td><input type="text" name="name" value="${sessionScope.id}" readonly></td></tr>
<!-- input name, value에 값을 넣어줘야 서버로 넘어감 -->
<tr><td>글제목</td><td><input type="text" name="subject" value="${boardDTO.subject }" required></td></tr>
<tr><td>첨부파일</td><td>새 파일 : <input type="file" name="file" ><br>
기존 파일 이름 : ${boardDTO.file}
<!-- 숨겨서 기존 파일 이름을 들고감 -->
<input type="hidden" name="oldfile" value="${boardDTO.file }"></td></tr>
<tr><td>글내용</td><td><textarea name="content" rows="10" cols="20">${boardDTO.content }</textarea></td></tr>
</table>
<div id="table_search">
<!-- location 자바스크립트 내장 객체 => 웹 브라우저 주소줄을 객체로 정의
location 내장객체 멤버 변수 => href 변수 : 웹 브라우저 주소줄 내용을 저장하고 있는 변수
=> href 변수 내용이 변경되어지면 웹 브라우저 주소도 변경
location.href='${pageContext.request.contextPath}/board/write -->
<input type="submit" value="글수정" class="btn">
<input type="button" value="글목록" class="btn" onclick="location.href='${pageContext.request.contextPath}/board/flist'">
</div>
</form>
<div class="clear"></div>
</article>
<!-- 게시판 -->
<!-- 본문들어가는 곳 -->
<div class="clear"></div>
<!-- 푸터들어가는 곳 -->
<jsp:include page="../inc/bottom.jsp" />
<!-- 푸터들어가는 곳 -->
</div>
</body>
</html>
BoardController
@PostMapping("fupdatePro")
public String fupdatePro(HttpServletRequest request, MultipartFile file) throws Exception{
System.out.println("BoardController fupdatePro()");
BoardDTO boardDTO = new BoardDTO();
//num, name, subject, content
boardDTO.setNum(Integer.parseInt(request.getParameter("num")));
boardDTO.setName(request.getParameter("name"));
boardDTO.setSubject(request.getParameter("subject"));
boardDTO.setContent(request.getParameter("content"));
//file, oldfile
if(file.isEmpty()) {
//첨부파일 없음 => 기존 파일 수정(oldfile)
System.out.println("첨부파일 없음");
boardDTO.setFile(request.getParameter("oldfile"));
} else {
//첨부파일이 있음 => 새 파일로 수정(file)
System.out.println("첨부파일 있음");
UUID uuid = UUID.randomUUID();
String filename = uuid.toString() + "_" + file.getOriginalFilename();
System.out.println(filename);
//업로드 원본 파일 file.getBytes() => upload폴더에 복사(파일 업로드)
//FileCopyUtils.copy(원본파일, 복사파일);
System.out.println(uploadPath);
FileCopyUtils.copy(file.getBytes(), new File(uploadPath,filename));
boardDTO.setFile(filename);
}
boardService.fupdateBoard(boardDTO);
return "redirect:/board/flist";
}
BoardService
public void fupdateBoard(BoardDTO boardDTO) {
System.out.println("BoardService fupdateBoard()");
boardDAO.fupdateBoard(boardDTO);
}
BoardDAO
public void fupdateBoard(BoardDTO boardDTO) {
System.out.println("BoardDAO deleteBoard()");
sqlSession.update(namespace+".fupdateBoard", boardDTO);
}
boardMapper
<update id="fupdateBoard">
update board
set subject = #{subject}, content = #{content}, file = #{file}
where num = #{num}
</update>
삭제
@GetMapping("/fdelete")
public String fdelete(BoardDTO boardDTO) {
System.out.println("BoardController fdelete()");
boardService.deleteBoard(boardDTO);
return "redirect:/board/flist";
}
이미지보이기(갤러리 게시판)
fcontent.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>center/fcontent.jsp</title>
<link href="${pageContext.request.contextPath}/resources/css/default.css" rel="stylesheet" type="text/css">
<link href="${pageContext.request.contextPath}/resources/css/subpage.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js" type="text/javascript"></script>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/ie7-squish.js" type="text/javascript"></script>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<!--[if IE 6]>
<script src="../script/DD_belatedPNG_0.0.8a.js"></script>
<script>
/* EXAMPLE */
DD_belatedPNG.fix('#wrap');
DD_belatedPNG.fix('#main_img');
</script>
<![endif]-->
</head>
<body>
<div id="wrap">
<!-- 헤더들어가는 곳 -->
<jsp:include page="../inc/top.jsp" />
<!-- 헤더들어가는 곳 -->
<!-- 본문들어가는 곳 -->
<!-- 메인이미지 -->
<div id="sub_img_center"></div>
<!-- 메인이미지 -->
<!-- 왼쪽메뉴 -->
<jsp:include page="../inc/left.jsp" />
<!-- 왼쪽메뉴 -->
<!-- 게시판 -->
<article>
<h1>File Content Notice</h1>
<table id="notice">
<tr><td>글번호</td><td>${boardDTO.num}</td></tr>
<tr><td>글쓴이</td><td>${boardDTO.name}</td></tr>
<tr><td>조회수</td><td>${boardDTO.readcount}</td></tr>
<tr><td>작성일</td><td>${boardDTO.date}</td></tr>
<tr><td>글제목</td><td>${boardDTO.subject}</td></tr>
<tr><td>첨부파일</td><td><a href="${pageContext.request.contextPath}/resources/upload/${boardDTO.file}" download>${boardDTO.file}</a>
<img src="${pageContext.request.contextPath}/resources/upload/${boardDTO.file}" width="100" height="100">
</td></tr>
<tr><td>글내용</td><td>${boardDTO.content}</td></tr>
</table>
<div id="table_search">
<c:if test="${! empty sessionScope.id }">
<c:if test="${sessionScope.id eq boardDTO.name }">
<input type="button" value="글수정" class="btn" onclick="location.href='${pageContext.request.contextPath}/board/fupdate?num=${boardDTO.num}'">
<input type="button" value="글삭제" class="btn" onclick="location.href='${pageContext.request.contextPath}/board/fdelete?num=${boardDTO.num}'">
</c:if>
</c:if>
<input type="button" value="글목록" class="btn" onclick="location.href='${pageContext.request.contextPath}/board/flist'">
</div>
<div class="clear"></div>
</article>
<!-- 게시판 -->
<!-- 본문들어가는 곳 -->
<div class="clear"></div>
<!-- 푸터들어가는 곳 -->
<jsp:include page="../inc/bottom.jsp" />
<!-- 푸터들어가는 곳 -->
</div>
</body>
</html>
중복체크
jquery홈페이지에서 js파일 다운로드 후 main-webapp-script에 jquery-3.7.1.min.js 넣어두기
join.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="${pageContext.request.contextPath}/resources/css/default.css" rel="stylesheet" type="text/css">
<link href="${pageContext.request.contextPath}/resources/css/subpage.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js" type="text/javascript"></script>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/ie7-squish.js" type="text/javascript"></script>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<!--[if IE 6]>
<script src="../script/DD_belatedPNG_0.0.8a.js"></script>
<script>
/* EXAMPLE */
DD_belatedPNG.fix('#wrap');
DD_belatedPNG.fix('#main_img');
</script>
<![endif]-->
<script src="${pageContext.request.contextPath}/resources/script/jquery-3.7.1.min.js"></script>
</head>
<body>
<div id="wrap">
<!-- 헤더들어가는 곳 -->
<!-- include 경로 => jsp 문법 => 상대적인 웹 경로를 적용. 현 파일을 기준으로 상대적으로 경로를 표시 -->
<jsp:include page="../inc/top.jsp" />
<!-- 헤더들어가는 곳 -->
<!-- 본문들어가는 곳 -->
<!-- 본문메인이미지 -->
<div id="sub_img_member"></div>
<!-- 본문메인이미지 -->
<!-- 왼쪽메뉴 -->
<nav id="sub_menu">
<ul>
<li><a href="#">Join us</a></li>
<li><a href="#">Privacy policy</a></li>
</ul>
</nav>
<!-- 왼쪽메뉴 -->
<!-- 본문내용 -->
<article>
<h1>Join Us</h1>
<form action="${pageContext.request.contextPath}/member/insertPro" id="join" method="post">
<!-- 비밀번호가 포함되어있으면 method를 post -->
<fieldset>
<legend>Basic Info</legend>
<label>User ID</label>
<input type="text" name="id" class="id">
<input type="button" value="dup.check" class="dup"><br>
<label></label>
<div id="dupdiv"></div><br>
<label>Password</label>
<input type="password" name="pw"><br>
<label>Retype Password</label>
<input type="password" name="pw2"><br>
<label>Name</label>
<input type="text" name="name"><br>
<label>E-Mail</label>
<input type="email" name="email"><br>
<label>Retype E-Mail</label>
<input type="email" name="email2"><br>
</fieldset>
<fieldset>
<legend>Optional</legend>
<label>Address</label>
<input type="text" name="address"><br>
<label>Phone Number</label>
<input type="text" name="phone"><br>
<label>Mobile Phone Number</label>
<input type="text" name="mobile"><br>
</fieldset>
<div class="clear"></div>
<div id="buttons">
<input type="submit" value="Submit" class="submit">
<input type="reset" value="Cancel" class="cancel">
</div>
</form>
</article>
<!-- 본문내용 -->
<!-- 본문들어가는 곳 -->
<div class="clear"></div>
<!-- 푸터들어가는 곳 -->
<jsp:include page="../inc/bottom.jsp" />
<!-- 푸터들어가는 곳 -->
</div>
<!-- Ajax(Asynchronous JavaScript and XML) 비동기적인 웹 애플리케이션의 제작을 위해 웹 개발 기법 -->
<script type="text/javascript">
//<input type="button" value="dup. check" class="dup">
$(function() {
//대상.함수()
$(".dup").click(function(){
// alert("클릭");
//$(대상).함수 이지만, ajax는 주소값
//속성이 여러 개 있을 경우
//alert($('.id').val()); //class="id" 아이디 상자 대상 => .val() value값
//${pageContext.request.contextPath}/member/idCheck?id=값
$.ajax({
//속성 : 값, 속성 : 값,...
url : '${pageContext.request.contextPath}/member/idCheck',
data : {'id' : $('.id').val()}, //data : {이름(아이디):값, 이름: 값}
success : function(result){
//result 출력 결과값
if(result=="iddup"){
result = "사용불가능한 아이디입니다.";
}else{
result = "사용가능한 아이디입니다.";
}
// alert(result);
// id="dupdiv" 결과값 넣기 => 대상에 html 문서를 넣기
$('#dupdiv').html(result);
}
});
});
// $(".dup").on("click",function(){
// alert("on클릭");
// });
});
</script>
</body>
</html>
MemberController
@GetMapping("/idCheck")
@ResponseBody
public String idCheck(MemberDTO memberDTO, HttpServletResponse response) {
System.out.println("MemberController idCheck()");
System.out.println(memberDTO);
MemberDTO memberDTO1 = memberService.getMember(memberDTO.getId());
System.out.println(memberDTO1);
//아이디가 있으면 memberDTO1 주소값 전달 => 아이디 중복
//아이디가 없으면 memberDTO1 null 전달 => 아이디 사용가능
String result ="";
if(memberDTO1 != null) {
//아이디 중복
//result = "사용 불가능한 아이디입니다.";
result = "iddup";
}else {
result = "idok";
//result = "사용 가능한 아이디입니다.";
}
System.out.println(result);
// 원래 return 이동할 주소 => ajax 처리 return 출력 결과 리턴 => 출력 결과 응답 (어노테이션@ResponseBody)
return result;
}
보통 AjaxController를 따로 두는 경우
AjaxController
package com.itwillbs.controller;
import javax.inject.Inject;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.itwillbs.domain.MemberDTO;
import com.itwillbs.service.MemberService;
@RestController
public class AjaxController {
@Inject
private MemberService memberService;
@GetMapping("/member/idCheck")
public String idCheck(MemberDTO memberDTO, HttpServletResponse response) {
System.out.println("MemberController idCheck()");
System.out.println(memberDTO);
MemberDTO memberDTO1 = memberService.getMember(memberDTO.getId());
System.out.println(memberDTO1);
//아이디가 있으면 memberDTO1 주소값 전달 => 아이디 중복
//아이디가 없으면 memberDTO1 null 전달 => 아이디 사용가능
String result ="";
if(memberDTO1 != null) {
//아이디 중복
//result = "사용 불가능한 아이디입니다.";
result = "iddup";
}else {
result = "idok";
//result = "사용 가능한 아이디입니다.";
}
System.out.println(result);
// 원래 return 이동할 주소 => ajax 처리 return 출력 결과 리턴 => 출력 결과 응답 (어노테이션@ResponseBody)
return result;
}
}
이런 식으로 중복확인하면 됨
728x90
'KDT > WEB' 카테고리의 다른 글
240223 WEB 댓글,대댓글 (0) | 2024.02.23 |
---|---|
2410220 WEB 메인에서 최신 글 보여주기, 게시판 검색 (0) | 2024.02.20 |
240215 WEB - 글 수정, 삭제, 파일 업로드 1 (0) | 2024.02.15 |
240213 WEB(펀웹5) (0) | 2024.02.13 |
240208 WEB(펀웹4(board)) (0) | 2024.02.08 |