<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>빙록의 공부</title>
    <link>https://qldfhrdmlrhdqn.tistory.com/</link>
    <description></description>
    <language>ko</language>
    <pubDate>Fri, 8 May 2026 07:32:33 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>빙록</managingEditor>
    <item>
      <title>69-3</title>
      <link>https://qldfhrdmlrhdqn.tistory.com/237</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;멈추고 파일 다시 지우고 다시 설정&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-filename=&quot;8.PNG&quot; data-origin-width=&quot;1603&quot; data-origin-height=&quot;515&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/bWcw2A/btsooKTbHCU/CZAxpJTRa1A0b1riRULJ30/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/bWcw2A/btsooKTbHCU/CZAxpJTRa1A0b1riRULJ30/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/bWcw2A/btsooKTbHCU/CZAxpJTRa1A0b1riRULJ30/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbWcw2A%2FbtsooKTbHCU%2FCZAxpJTRa1A0b1riRULJ30%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1603&quot; height=&quot;515&quot; data-filename=&quot;8.PNG&quot; data-origin-width=&quot;1603&quot; data-origin-height=&quot;515&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;$ sudo systemctl stop tomcat &lt;br /&gt;$ sudo rm -rf /op/tomcat/tomcat-10/webapps/boot &lt;br /&gt;$ sudo rm -rf /op/tomcat/tomcat-10/webapps/boot.war &lt;br /&gt;$ sudo mv boot-0.0.1-SNAPSHOT.war /opt/tomcat/tomcat-10/webapps/boot.war &lt;br /&gt;$ sudo systemctl start tomcat &lt;br /&gt;$ sudo systemctl status tomcat&lt;/p&gt;</description>
      <category>프로그래밍/HTML</category>
      <author>빙록</author>
      <guid isPermaLink="true">https://qldfhrdmlrhdqn.tistory.com/237</guid>
      <comments>https://qldfhrdmlrhdqn.tistory.com/237#entry237comment</comments>
      <pubDate>Thu, 20 Jul 2023 16:30:16 +0900</pubDate>
    </item>
    <item>
      <title>69-2</title>
      <link>https://qldfhrdmlrhdqn.tistory.com/236</link>
      <description>&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-filename=&quot;5.PNG&quot; data-origin-width=&quot;1569&quot; data-origin-height=&quot;285&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/cn43xj/btsomPuCRGW/D55SzG3aTTeiv3H1b79kYk/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/cn43xj/btsomPuCRGW/D55SzG3aTTeiv3H1b79kYk/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/cn43xj/btsomPuCRGW/D55SzG3aTTeiv3H1b79kYk/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fcn43xj%2FbtsomPuCRGW%2FD55SzG3aTTeiv3H1b79kYk%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1569&quot; height=&quot;285&quot; data-filename=&quot;5.PNG&quot; data-origin-width=&quot;1569&quot; data-origin-height=&quot;285&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-filename=&quot;6.PNG&quot; data-origin-width=&quot;979&quot; data-origin-height=&quot;512&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/va7x0/btsooHWlPq0/iWpcU1XkX1nhFD5phNh540/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/va7x0/btsooHWlPq0/iWpcU1XkX1nhFD5phNh540/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/va7x0/btsooHWlPq0/iWpcU1XkX1nhFD5phNh540/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fva7x0%2FbtsooHWlPq0%2FiWpcU1XkX1nhFD5phNh540%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;979&quot; height=&quot;512&quot; data-filename=&quot;6.PNG&quot; data-origin-width=&quot;979&quot; data-origin-height=&quot;512&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;외부 제한&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-filename=&quot;7.PNG&quot; data-origin-width=&quot;1014&quot; data-origin-height=&quot;192&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/dl8Sog/btsonxAcpsA/OK5jxDHlAC4Ph28zKCteOK/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/dl8Sog/btsonxAcpsA/OK5jxDHlAC4Ph28zKCteOK/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/dl8Sog/btsonxAcpsA/OK5jxDHlAC4Ph28zKCteOK/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fdl8Sog%2FbtsonxAcpsA%2FOK5jxDHlAC4Ph28zKCteOK%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1014&quot; height=&quot;192&quot; data-filename=&quot;7.PNG&quot; data-origin-width=&quot;1014&quot; data-origin-height=&quot;192&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;</description>
      <category>프로그래밍/HTML</category>
      <author>빙록</author>
      <guid isPermaLink="true">https://qldfhrdmlrhdqn.tistory.com/236</guid>
      <comments>https://qldfhrdmlrhdqn.tistory.com/236#entry236comment</comments>
      <pubDate>Thu, 20 Jul 2023 16:01:23 +0900</pubDate>
    </item>
    <item>
      <title>69-1</title>
      <link>https://qldfhrdmlrhdqn.tistory.com/235</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;color: #000000;&quot;&gt;run as &amp;gt;&amp;gt;&amp;nbsp;maven&amp;nbsp;build 단축키 있는거&amp;nbsp;packagge&lt;/span&gt;&lt;/p&gt;
&lt;div style=&quot;background-color: #191d1f;&quot;&gt;
&lt;div style=&quot;background-color: #191d1f; color: #c7cdd1;&quot;&gt;&lt;img style=&quot;text-align: center; caret-color: transparent; color: #333333; letter-spacing: 0px;&quot; src=&quot;https://blog.kakaocdn.net/dn/c4dR1R/btsonlGlRzG/KoLy6To7WLNDbY59AYiMa0/img.png&quot; data-origin-width=&quot;1218&quot; data-origin-height=&quot;581&quot; data-filename=&quot;1.PNG&quot; data-is-animation=&quot;false&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-filename=&quot;2.PNG&quot; data-origin-width=&quot;979&quot; data-origin-height=&quot;512&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/p5U0M/btsohp4z1Eo/TWnSQR9rXc56ojTnPZUmuK/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/p5U0M/btsohp4z1Eo/TWnSQR9rXc56ojTnPZUmuK/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/p5U0M/btsohp4z1Eo/TWnSQR9rXc56ojTnPZUmuK/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fp5U0M%2Fbtsohp4z1Eo%2FTWnSQR9rXc56ojTnPZUmuK%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;979&quot; height=&quot;512&quot; data-filename=&quot;2.PNG&quot; data-origin-width=&quot;979&quot; data-origin-height=&quot;512&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-filename=&quot;3.PNG&quot; data-origin-width=&quot;700&quot; data-origin-height=&quot;490&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/KvNYh/btsonHbgTR4/17i78g4WLnWHTcViJqbb5K/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/KvNYh/btsonHbgTR4/17i78g4WLnWHTcViJqbb5K/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/KvNYh/btsonHbgTR4/17i78g4WLnWHTcViJqbb5K/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FKvNYh%2FbtsonHbgTR4%2F17i78g4WLnWHTcViJqbb5K%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;700&quot; height=&quot;490&quot; data-filename=&quot;3.PNG&quot; data-origin-width=&quot;700&quot; data-origin-height=&quot;490&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-filename=&quot;4.PNG&quot; data-origin-width=&quot;1821&quot; data-origin-height=&quot;880&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/YZbyY/btsonJfQ1Ok/Sm3lkmaQhK7eoj66v75u00/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/YZbyY/btsonJfQ1Ok/Sm3lkmaQhK7eoj66v75u00/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/YZbyY/btsonJfQ1Ok/Sm3lkmaQhK7eoj66v75u00/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FYZbyY%2FbtsonJfQ1Ok%2FSm3lkmaQhK7eoj66v75u00%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1821&quot; height=&quot;880&quot; data-filename=&quot;4.PNG&quot; data-origin-width=&quot;1821&quot; data-origin-height=&quot;880&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;figure class=&quot;imageblock alignCenter&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-filename=&quot;5.PNG&quot; data-origin-width=&quot;1569&quot; data-origin-height=&quot;285&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/bRFbng/btsogZd0DZU/y4UU9uq6vgLd2iO2u5DIm1/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/bRFbng/btsogZd0DZU/y4UU9uq6vgLd2iO2u5DIm1/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/bRFbng/btsogZd0DZU/y4UU9uq6vgLd2iO2u5DIm1/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbRFbng%2FbtsogZd0DZU%2Fy4UU9uq6vgLd2iO2u5DIm1%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1569&quot; height=&quot;285&quot; data-filename=&quot;5.PNG&quot; data-origin-width=&quot;1569&quot; data-origin-height=&quot;285&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;pre id=&quot;code_1689832428787&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;package com.care.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication(exclude = SecurityAutoConfiguration.class) // 자동으로 제거 
public class BootApplication extends SpringBootServletInitializer{
	// http://loacalhost/logout
	
	@Override
	protected SpringApplicationBuilder createSpringApplicationBuilder() {
		return super.createSpringApplicationBuilder();
	}
	
	public static void main(String[] args) {
		SpringApplication.run(BootApplication.class, args);
		
	}

}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>프로그래밍/HTML</category>
      <author>빙록</author>
      <guid isPermaLink="true">https://qldfhrdmlrhdqn.tistory.com/235</guid>
      <comments>https://qldfhrdmlrhdqn.tistory.com/235#entry235comment</comments>
      <pubDate>Thu, 20 Jul 2023 14:54:15 +0900</pubDate>
    </item>
    <item>
      <title>68-4</title>
      <link>https://qldfhrdmlrhdqn.tistory.com/234</link>
      <description>&lt;pre id=&quot;code_1689660184176&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;public void getUserInfo() {
		String reqUrl = &quot;https://kapi.kakao.com/v2/user/me&quot;;
		HttpURLConnection conn;
		
		try {
			URL url = new URL(reqUrl);
			conn = (HttpURLConnection)url.openConnection();
			
			conn.setRequestMethod(&quot;POST&quot;); 
			conn.setRequestProperty(&quot;Authorization&quot;, &quot;Bearer &quot; + accessToken); //Authorization: Bearer ${ACCESS_TOKEN}
			
			ObjectMapper om = new ObjectMapper();
			JsonNode jsonTree = om.readTree(conn.getInputStream());
			
			System.out.println(&quot;jsonTree : &quot;+jsonTree);
			System.out.println(&quot;kakao_account : &quot; + jsonTree.get(&quot;kakao_account&quot;));
			
			JsonNode kakaoAccount = jsonTree.get(&quot;kakao_account&quot;);
			System.out.println(&quot;profile : &quot; + kakaoAccount.get(&quot;profile&quot;));
			System.out.println(&quot;email : &quot; + kakaoAccount.get(&quot;email&quot;));
			System.out.println(&quot;age_range : &quot; + kakaoAccount.get(&quot;age_range&quot;));
			System.out.println(&quot;gender : &quot; + kakaoAccount.get(&quot;gender&quot;));
			System.out.println(&quot;nickname : &quot; + kakaoAccount.get(&quot;profile&quot;).get(&quot;nickname&quot;));
			
		}catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void unLink() {
		/** 로그아웃 되어있는 상태면 오류 */
		String reqUrl = &quot;https://kapi.kakao.com/v1/user/unlink&quot;;
		HttpURLConnection conn;
		try {
			URL url = new URL(reqUrl);
			conn = (HttpURLConnection)url.openConnection();
			conn.setRequestMethod(&quot;POST&quot;); 
			conn.setRequestProperty(&quot;Authorization&quot;, &quot;Bearer &quot; + accessToken); 
			
			int responseCode = conn.getResponseCode(); //결과 코드가 200이면 성공
			System.out.println(&quot;responseCode:&quot;+responseCode);
			
			ObjectMapper om = new ObjectMapper();
			JsonNode jsonTree = om.readTree(conn.getInputStream());
			System.out.println(&quot;id : &quot;+jsonTree.get(&quot;id&quot;));
			
		}catch (IOException e) {
			e.printStackTrace();
		}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>프로그래밍/HTML</category>
      <author>빙록</author>
      <guid isPermaLink="true">https://qldfhrdmlrhdqn.tistory.com/234</guid>
      <comments>https://qldfhrdmlrhdqn.tistory.com/234#entry234comment</comments>
      <pubDate>Tue, 18 Jul 2023 15:03:14 +0900</pubDate>
    </item>
    <item>
      <title>68-3 토큰</title>
      <link>https://qldfhrdmlrhdqn.tistory.com/233</link>
      <description>&lt;pre id=&quot;code_1689650620032&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;package com.care.dbQuiz.member;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

@Service
public class KakaoService {

	public void getAccessToken(String code) {
		String reqUrl = &quot;https://kauth.kakao.com/oauth/token&quot;;
		String reqParam = &quot;grant_type=authorization_code&quot;;
		reqParam += &quot;&amp;amp;client_id=231dcfa0f6c9f5d6db11c3d33c9b755c&quot;;
		reqParam += &quot;&amp;amp;redirect_uri=http://localhost:8065/dbQuiz/kakaoLogin&quot;;
		reqParam += &quot;&amp;amp;code=&quot;+code;
		
		HttpURLConnection conn;
		try {
			URL url = new URL(reqUrl); //POST 요청에 필요로 요구하는 파라미터 스트림을 통해 전송
			conn = (HttpURLConnection)url.openConnection();
			conn.setRequestMethod(&quot;POST&quot;); //POST 요청을위해 기본값 false에서 setDoOut으로 true변경
			conn.setDoOutput(true);//post 매소드를 이용해서 데이터를 전달하기위한설정
			
			//기본 OutputStram을 통해 문자열로 처리할수있는 OutputStreamWriter변환후 처리속도를 빠르게 처리하기위해
			//BufferedWriter변환한다
			BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream()));
			bw.write(reqParam);
			bw.flush();
			
			int responseCode = conn.getResponseCode(); //결과 코드가 200이면 성공
			System.out.println(&quot;responseCode:&quot;+responseCode);
			
			// 요청을 통해 얻은 JSON타입의 Response 메세지 읽어오기 (반복문)
//			BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
//			String line =&quot;&quot;, result=&quot;&quot;;
//			while((line = br.readLine()) != null){
//				result += line;
//			}
			
			// 요청을 통해 얻은 JSON타입의 Response 메세지 읽어오기
			InputStreamReader isr = new InputStreamReader(conn.getInputStream());
			ObjectMapper om = new ObjectMapper();
			Map&amp;lt;String, String&amp;gt; map = null;
			map = om.readValue(isr, new TypeReference&amp;lt;Map&amp;lt;String, String&amp;gt;&amp;gt;() {} );
			
			System.out.println(&quot;access_token : &quot;+map.get(&quot;access_token&quot;));
			System.out.println(&quot;scope&quot;+map.get(&quot;scope&quot;));
			
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
//curl -v -X POST &quot;https://kauth.kakao.com/oauth/token&quot; \
//-H &quot;Content-Type: application/x-www-form-urlencoded&quot; \
//-d &quot;grant_type=authorization_code&quot; \
//-d &quot;client_id=${REST_API_KEY}&quot; \
//--data-urlencode &quot;redirect_uri=${REDIRECT_URI}&quot; \
//-d &quot;code=${AUTHORIZE_CODE}&quot;&lt;/code&gt;&lt;/pre&gt;</description>
      <category>프로그래밍/HTML</category>
      <author>빙록</author>
      <guid isPermaLink="true">https://qldfhrdmlrhdqn.tistory.com/233</guid>
      <comments>https://qldfhrdmlrhdqn.tistory.com/233#entry233comment</comments>
      <pubDate>Tue, 18 Jul 2023 12:23:46 +0900</pubDate>
    </item>
    <item>
      <title>68-2</title>
      <link>https://qldfhrdmlrhdqn.tistory.com/232</link>
      <description>&lt;pre id=&quot;code_1689647370241&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;package com.care.dbQuiz.member;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import org.springframework.stereotype.Service;

@Service
public class KakaoService {

	public void getAccessToken(String code) {
		String reqUrl = &quot;https://kauth.kakao.com/oauth/token&quot;;
		String reqParam = &quot;grant_type=authorization_code&quot;;
		reqParam += &quot;&amp;amp;client_id=231dcfa0f6c9f5d6db11c3d33c9b755c&quot;;
		reqParam += &quot;&amp;amp;redirect_uri=http://localhost:8065/dbQuiz/kakaoLogin&quot;;
		reqParam += &quot;&amp;amp;code=&quot;+code;
		
		HttpURLConnection conn;
		try {
			URL url = new URL(reqUrl); //POST 요청에 필요로 요구하는 파라미터 스트림을 통해 전송
			conn = (HttpURLConnection)url.openConnection();
			conn.setRequestMethod(&quot;POST&quot;); //POST 요청을위해 기본값 false에서 setDoOut으로 true변경
			conn.setDoOutput(true);//post 매소드를 이용해서 데이터를 전달하기위한설정
			
			//기본 OutputStram을 통해 문자열로 처리할수있는 OutputStreamWriter변환후 처리속도를 빠르게 처리하기위해
			//BufferedWriter변환한다
			BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream()));
			bw.write(reqParam);
			bw.flush();
			
			int responseCode = conn.getResponseCode(); //결과 코드가 200이면 성공
			System.out.println(&quot;responseCode:&quot;+responseCode);
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
//curl -v -X POST &quot;https://kauth.kakao.com/oauth/token&quot; \
//-H &quot;Content-Type: application/x-www-form-urlencoded&quot; \
//-d &quot;grant_type=authorization_code&quot; \
//-d &quot;client_id=${REST_API_KEY}&quot; \
//--data-urlencode &quot;redirect_uri=${REDIRECT_URI}&quot; \
//-d &quot;code=${AUTHORIZE_CODE}&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689647361218&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;@Autowired private KakaoService kakao;
	@GetMapping(&quot;kakaoLogin&quot;)
	public void kakaoLogin(String code) {
		System.out.println(&quot;code:&quot;+code); 	
		kakao.getAccessToken(code);
	}&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689647351627&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;lt;tr&amp;gt;
		&amp;lt;td&amp;gt;
			&amp;lt;a href=&quot;https://kauth.kakao.com/oauth/authorize?response_type=code&amp;amp;client_id=231dcfa0f6c9f5d6db11c3d33c9b755c&amp;amp;&amp;amp;redirect_uri=http://localhost:8065/dbQuiz/kakaoLogin&quot;			
			&amp;gt;	
				&amp;lt;img src=&quot;https://k.kakaocdn.net/14/dn/btroDszwNrM/I6efHub1SN5KCJqLm1Ovx1/o.jpg&quot;&amp;gt;
			&amp;lt;/a&amp;gt;
		&amp;lt;/td&amp;gt;
	&amp;lt;/tr&amp;gt;&lt;/code&gt;&lt;/pre&gt;</description>
      <category>프로그래밍/HTML</category>
      <author>빙록</author>
      <guid isPermaLink="true">https://qldfhrdmlrhdqn.tistory.com/232</guid>
      <comments>https://qldfhrdmlrhdqn.tistory.com/232#entry232comment</comments>
      <pubDate>Tue, 18 Jul 2023 12:23:22 +0900</pubDate>
    </item>
    <item>
      <title>68-1</title>
      <link>https://qldfhrdmlrhdqn.tistory.com/231</link>
      <description>&lt;pre id=&quot;code_1689640943391&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;package com.care.dbQuiz.member;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import oracle.jdbc.proxy.annotation.Post;

@Controller
public class MemberController {
	@Autowired private MemberService service;
	@Autowired private HttpSession session;
	
	@RequestMapping(&quot;index&quot;)
	public String index() {
		return &quot;member/index&quot;;
	}

	@RequestMapping(&quot;header&quot;)
	public String header() {
		return &quot;default/header&quot;;
	}
	@RequestMapping(&quot;main&quot;)
	public String main() {
		return &quot;default/main&quot;;
	}
	@RequestMapping(&quot;footer&quot;)
	public String footer() {
		return &quot;default/footer&quot;;
	}
	/* http://localhost:8086/dbQuiz/login */
	@GetMapping(&quot;login&quot;)
	public String login() {
		return &quot;member/login&quot;;
	}
	
	@PostMapping(&quot;loginProc&quot;)
	public String loginProc(MemberDTO member) {
		String result = service.loginProc(member);
		if(result.equals(&quot;로그인 성공&quot;)) {
			return &quot;redirect:index&quot;;
		}
		return &quot;member/login&quot;;
	}
	
	/* http://localhost:8086/dbQuiz/register */
	@GetMapping(&quot;register&quot;)
	public String register() {
		return &quot;member/register&quot;;
	}
	
	@PostMapping(&quot;registerProc&quot;)
	public String registerProc(MemberDTO member, String confirm) {
		String result = service.registerProc(member, confirm);
		if(result.equals(&quot;회원 등록 완료&quot;)) {
			return &quot;redirect:index&quot;;
		}
		return &quot;member/register&quot;;
	}
	
	@RequestMapping(&quot;memberInfo&quot;)
	public String memberInfo(
			@RequestParam(value=&quot;currentPage&quot;, required = false)String cp,
			String select, String search, Model model) {
		service.memberInfo(cp, select, search, model);
		return &quot;member/memberInfo&quot;;
	}
	
	@RequestMapping(&quot;userInfo&quot;)
	public String userInfo(String id, 
			@RequestParam(value=&quot;currentPage&quot;, required = false)String cp, 
			Model model) {
		
		if(session.getAttribute(&quot;id&quot;) == null ) {
			return &quot;redirect:login&quot;;
		}
		MemberDTO member = service.userInfo(id);
		if(member == null) {
			return &quot;redirect:memberInfo?currentPage=&quot;+cp;
		}
		model.addAttribute(&quot;userInfo&quot;, member);
		return &quot;member/userInfo&quot;;
	}
	
	@RequestMapping(&quot;logout&quot;)
	public String logout() {
		session.invalidate();
		return &quot;forward:index&quot;;
	}
	
	/* http://localhost:8086/dbQuiz/update */
	@GetMapping(&quot;update&quot;)
	public String update() {
		String id = (String)session.getAttribute(&quot;id&quot;);
		if(id == null || id.isEmpty()) {
			return &quot;redirect:login&quot;;
		}
		return &quot;member/update&quot;;
	}
	@PostMapping(&quot;updateProc&quot;)
	public String updateProc(MemberDTO member, String confirm) {
		String id = (String)session.getAttribute(&quot;id&quot;);
		if(id == null || id.isEmpty()) {
			return &quot;redirect:login&quot;;
		}
		member.setId(id);
		String result = service.updateProc(member, confirm);
		if(result.equals(&quot;회원 정보 수정 완료&quot;)) {
			return &quot;forward:logout&quot;;
		}
		return &quot;member/update&quot;;
	}
	
	
	/* http://localhost:8086/dbQuiz/delete */
	@GetMapping(&quot;delete&quot;)
	public String delete() {
		String id = (String)session.getAttribute(&quot;id&quot;);
		if(id == null || id.isEmpty()) {
			return &quot;redirect:login&quot;;
		}
		return &quot;member/delete&quot;;
	}
	
	@PostMapping(&quot;deleteProc&quot;)
	public String deleteProc(String pw, String confirmPw, Model model) {
		String id = (String)session.getAttribute(&quot;id&quot;);
		if(id == null || id.isEmpty()) {
			return &quot;redirect:login&quot;;
		}
		
		String result = service.deleteProc(id, pw, confirmPw);
		model.addAttribute(&quot;msg&quot;, result);
		if(result.equals(&quot;회원 정보 삭제 완료&quot;)) {
			return &quot;forward:logout&quot;;
		}
		return &quot;member/delete&quot;;
	}
	
	@ResponseBody
	@PostMapping(value=&quot;sendEmail&quot;, produces=&quot;text/plan; charset=utf-8&quot;)
	public String sendEmail(@RequestBody(required = false)String email) {
		return service.sendEmail(email);
	}
	
	@ResponseBody
	@PostMapping(value=&quot;sendAuth&quot;, produces=&quot;text/plan; charset=utf-8&quot;)
	public String sendAuth(@RequestBody(required = false)String auth) {
		System.out.println(&quot;sendAuth()&quot;);
		
		return service.sendAuth(auth);
	}
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689640930054&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;package com.care.dbQuiz.member;

import java.util.ArrayList;
import java.util.Random;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import com.care.dbQuiz.common.PageService;


@Service
public class MemberService {
	@Autowired private MemberMapper memberMapper;
	@Autowired private HttpSession session;
	
	public String loginProc(MemberDTO member) {
		if(member.getId() == null || member.getId().isEmpty()) {
			return &quot;아이디를 입력하세요.&quot;;
		}
		
		if(member.getPw() == null || member.getPw().isEmpty()) {
			return &quot;비밀번호를 입력하세요.&quot;;
		}
		
		MemberDTO result = memberMapper.loginProc(member.getId());
		if(result != null){
			BCryptPasswordEncoder bpe = new BCryptPasswordEncoder();
			
			 //raw:원본 , encode:암호값을 가져와서 해독한다
			if(bpe.matches(member.getPw(), result.getPw())) {
				session.setAttribute(&quot;id&quot;, result.getId());
				session.setAttribute(&quot;userName&quot;, result.getUserName());

				
				session.setAttribute(&quot;address&quot;, result.getAddress());
				session.setAttribute(&quot;mobile&quot;, result.getMobile());
				return &quot;로그인 성공&quot;;
			}
			
		}
		
		return &quot;아이디/비밀번호를 확인 후 다시 시도하세요.&quot;;
	}

	public String registerProc(MemberDTO member, String confirm) {
		if(member.getId() == null || member.getId().isEmpty()) {
			return &quot;아이디를 입력하세요.&quot;;
		}
		
		if(member.getPw() == null || member.getPw().isEmpty()) {
			return &quot;비밀번호를 입력하세요.&quot;;
		}
		
		if(member.getPw().equals(confirm) == false) {
			return &quot;두 비밀번호를 일치하여 입력하세요.&quot;;
		}
		
		if(member.getUserName() == null || member.getUserName().isEmpty()) {
			return &quot;이름을 입력하세요.&quot;;
		}
		
		
		
//		System.out.println(&quot;평문 비밀번호 : &quot;+member.getPw());
//		System.out.println(&quot;암호화된 비밀번호 : &quot;+crytPassword);
//		System.out.println(&quot;암호화된 비밀번호 길이 : &quot;+crytPassword.length());
		
		MemberDTO result = memberMapper.loginProc(member.getId());
		
	
		
		if(result == null) {
			BCryptPasswordEncoder bpe = new BCryptPasswordEncoder();
			String crytPassword = bpe.encode(member.getPw());
			member.setPw(crytPassword);
			memberMapper.registerProc(member);
			return &quot;회원 등록 완료&quot;;
		}
		
		return &quot;이미 가입된 아이디 입니다.&quot;;
	}

	public void memberInfo(String cp, String select, String search, Model model) {
		if(select == null){
			select = &quot;&quot;;
		}
		
		int currentPage = 1;
		try{
			currentPage = Integer.parseInt(cp);
		}catch(Exception e){
			currentPage = 1;
		}
		
		int pageBlock = 3; // 한 페이지에 보일 데이터의 수 
		int end = pageBlock * currentPage; // 테이블에서 가져올 마지막 행번호
		int begin = end - pageBlock + 1; // 테이블에서 가져올 시작 행번호
	
		ArrayList&amp;lt;MemberDTO&amp;gt; members = memberMapper.memberInfo(begin, end, select, search);
		int totalCount = memberMapper.count(select, search);
		String url = &quot;memberInfo?select=&quot;+select+&quot;&amp;amp;search=&quot;+search+&quot;&amp;amp;currentPage=&quot;;
		String result = PageService.printPage(url, currentPage, totalCount, pageBlock);
		
		model.addAttribute(&quot;members&quot;, members);
		model.addAttribute(&quot;result&quot;, result);
		model.addAttribute(&quot;currentPage&quot;, currentPage);
	}

	public MemberDTO userInfo(String id) {
		if(id == null || id.isEmpty()) {
			return null;
		}
		
		String sessionId = (String)session.getAttribute(&quot;id&quot;);
		if(sessionId.equals(id) == false &amp;amp;&amp;amp; sessionId.equals(&quot;admin&quot;) == false)
			return null;
		
//		MemberDTO result = memberMapper.loginProc(id);
		return memberMapper.loginProc(id);
	}

	public String updateProc(MemberDTO member, String confirm) {
		if(member.getPw() == null || member.getPw().isEmpty()) {
			return &quot;비밀번호를 입력하세요.&quot;;
		}
		
		if(member.getPw().equals(confirm) == false) {
			return &quot;두 비밀번호를 일치하여 입력하세요.&quot;;
		}
		
		if(member.getUserName() == null || member.getUserName().isEmpty()) {
			return &quot;이름을 입력하세요.&quot;;
		}
		BCryptPasswordEncoder bpe = new BCryptPasswordEncoder();
		String crytPassword = bpe.encode(member.getPw());
		member.setPw(crytPassword);
		int result = memberMapper.updateProc(member);
		if(result == 1)
			return &quot;회원 정보 수정 완료&quot;;
		return &quot;회원 정보 수정 실패&quot;;
	}

	public String deleteProc(String id, String pw, String confirmPw) {
		if(pw == null || pw.isEmpty()) {
			return &quot;비밀번호를 입력하세요.&quot;;
		}
		
		if(pw.equals(confirmPw) == false) {
			return &quot;두 비밀번호를 일치하여 입력하세요.&quot;;
		}
		
		MemberDTO member = memberMapper.loginProc(id);
		
		if(member != null) {
			BCryptPasswordEncoder bpe = new BCryptPasswordEncoder();
			if(bpe.matches(pw, member.getPw())) {
				memberMapper.delete(member.getId());
				session.invalidate();
				return &quot;회원 정보 삭제 완료&quot;;
			}
			
		}
		return &quot;비밀번호를 확인 후 다시 시도하세요.&quot;;
	}

	
	
	@Autowired private MailService mailService;
	private String content;
	public String sendEmail(String email) {
		if(email == null || email.isEmpty())
			return &quot;이메일을 확인 후 다시 입력하세요.&quot;;
		Random r = new Random();
		// 1,000,000 
		// 100 000 , 001234
	
		content = String.format(&quot;%06d&quot;, r.nextInt(1000000));
		System.out.println(&quot;인증번호 : &quot; + content);
		String msg = mailService.sendMail(email, &quot;인증번호가 도착했습니다&quot;, content);
		if(msg.equals(&quot;입력한 이메일에서 인증번호를 확인하세요.&quot;)== false) {
			content =&quot; &quot;;
		}
		
		return msg;
	}

	
	public String sendAuth(String auth) {
		if(auth == null || auth.isEmpty())
			return &quot;인증번호를 입력후 다시 시도하세요&quot;;
		
		if(content == null || content.isEmpty())
			return &quot;인증번호를 입력후 다시 시도하세요&quot;;
		
		if(auth.equals(content)) {
			return &quot;인증에 성공하였습니다.&quot;;
		}
		
		return &quot;인증 실패&quot;;
	}
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689640887199&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot;
    pageEncoding=&quot;UTF-8&quot;%&amp;gt;
&amp;lt;%@ taglib uri=&quot;http://java.sun.com/jsp/jstl/core&quot; prefix=&quot;c&quot;%&amp;gt;
&amp;lt;c:import url=&quot;/header&quot;&amp;gt;&amp;lt;/c:import&amp;gt;

&amp;lt;script src=&quot;//t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script&amp;gt;

    //본 예제에서는 도로명 주소 표기 방식에 대한 법령에 따라, 내려오는 데이터를 조합하여 올바른 주소를 구성하는 방법을 설명합니다.
    function execDaumPostcode() {
        new daum.Postcode({
            oncomplete: function(data) {
            	if(data.userSelectedType === 'R'){
            		document.getElementById('address').value= data.roadAddress;
            	}
            	else{
            		document.getElementById('address').value= data.jibunAddress;
            	}
            	document.getElementById('postcode').value= data.zonecode;
            	/*
	            	console.log(data.userSelectedType)
	            	console.log(data.jibunAddress)
	            	console.log(data.roadAddress)
	            	console.log(data.zonecode)
            	*/
            }
        }).open();
    }
    var xhr;
    
    function sendEmail() {
    	xhr = new XMLHttpRequest();
    	xhr.open('post', 'sendEmail');
    	xhr.send(document.getElementById('email').value);
 		xhr.onreadystatechange = resProc
    	
	}
    
    function sendAuth() {
    	if(xhr == null){
    		document.getElementById('msg').innerHTML = '이메일 주소를 전송후 사용';
    	}
    	xhr.open('post', 'sendAuth');
    	xhr.send(document.getElementById('auth').value);
 		xhr.onreadystatechange = AuthProc
	}
    
    function resProc() {
    	if(xhr.readyState === 4 &amp;amp;&amp;amp; xhr.status === 200){
    		document.getElementById('msg').innerHTML = xhr.responseText;
    	}
	}
    

    function AuthProc() {
    	if(xhr.readyState === 4 &amp;amp;&amp;amp; xhr.status === 200){
    		document.getElementById('msg').innerHTML = xhr.responseText;
    	}
    	
    	if(xhr.responseText === '인증에 성공하였습니다.'){
    		
    		document.getElementById('auth').style='display:none';
    		document.getElementById('authBtn').style='display:none';
    		document.getElementById('email').style='display:none';
    		document.getElementById('emailBtn').style='display:none';
    		document.getElementById('registerBtn').style='display:inline';
    	}
    	else{
    		document.getElementById('registerBtn').style='display:none';
    	}
    	
	}
    
   
&amp;lt;/script&amp;gt;

&amp;lt;div align=&quot;center&quot;&amp;gt;
	&amp;lt;h3 id =&quot;msg&quot;&amp;gt;&amp;lt;/h3&amp;gt;
	&amp;lt;h1&amp;gt;회원 등록&amp;lt;/h1&amp;gt;
	&amp;lt;table &amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;
	&amp;lt;form action=&quot;registerProc&quot; method=&quot;post&quot; id=&quot;f&quot;&amp;gt;
		&amp;lt;input type=&quot;text&quot; name=&quot;id&quot; placeholder=&quot;아이디&quot; id=&quot;id&quot;&amp;gt; (*필수 항목) &amp;lt;br&amp;gt;
		&amp;lt;input type=&quot;password&quot; name=&quot;pw&quot; placeholder=&quot;비밀번호&quot; id=&quot;pw&quot;&amp;gt;&amp;lt;br&amp;gt;
		&amp;lt;input type=&quot;password&quot; name=&quot;confirm&quot; placeholder=&quot;비밀번호 확인 &quot; id=&quot;confirm&quot;
		onchange=&quot;pwCheck()&quot;&amp;gt;
	
		&amp;lt;label id=&quot;label&quot; &amp;gt;&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
		&amp;lt;input type=&quot;text&quot; name=&quot;userName&quot; id=&quot;userName&quot; placeholder=&quot;이름&quot; &amp;gt;&amp;lt;br&amp;gt;
		
		&amp;lt;input type=&quot;text&quot; id=&quot;postcode&quot; name=&quot;postcode&quot; placeholder=&quot;우편번호&quot;&amp;gt;
		&amp;lt;input type=&quot;button&quot; onclick=&quot;execDaumPostcode()&quot; value=&quot;우편번호 찾기&quot;&amp;gt;&amp;lt;br&amp;gt;
		&amp;lt;input type=&quot;text&quot; id=&quot;address&quot; name=&quot;address&quot; placeholder=&quot;도로명주소&quot;&amp;gt;
		&amp;lt;span id=&quot;guide&quot; style=&quot;color:#999;display:none&quot;&amp;gt;&amp;lt;/span&amp;gt;
		&amp;lt;input type=&quot;text&quot; id=&quot;detailAddress&quot; name=&quot;detailAddress&quot; placeholder=&quot;상세주소&quot;&amp;gt;
	
		&amp;lt;input type=&quot;text&quot; name=&quot;mobile&quot; placeholder=&quot;전화번호&quot; &amp;gt;&amp;lt;br&amp;gt;
		
		&amp;lt;input type=&quot;text&quot; id=&quot;email&quot;  placeholder=&quot;이메일&quot;&amp;gt;
		&amp;lt;input type=&quot;button&quot; id =&quot;emailBtn&quot; onclick=&quot;sendEmail()&quot; value=&quot;이메일 주소 전송&quot;&amp;gt;&amp;lt;br&amp;gt;
		&amp;lt;input type=&quot;text&quot; id=&quot;auth&quot;  placeholder=&quot;인증번호&quot;&amp;gt;
		&amp;lt;input type=&quot;button&quot; id =&quot;authBtn&quot; onclick=&quot;sendAuth()&quot; value=&quot;인증번호 전송&quot;&amp;gt;&amp;lt;br&amp;gt;
		
		&amp;lt;input type=&quot;button&quot; id = &quot;registerBtn&quot; value=&quot;회원가입&quot; onclick=&quot;allCheck()&quot;&amp;gt;
		&amp;lt;input type=&quot;button&quot; value=&quot;취소&quot; onclick=&quot;location.href='index'&quot;&amp;gt;&amp;lt;br&amp;gt;
	&amp;lt;/form&amp;gt;
	&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;c:import url=&quot;/footer&quot;&amp;gt;&amp;lt;/c:import&amp;gt;&lt;/code&gt;&lt;/pre&gt;</description>
      <category>프로그래밍/HTML</category>
      <author>빙록</author>
      <guid isPermaLink="true">https://qldfhrdmlrhdqn.tistory.com/231</guid>
      <comments>https://qldfhrdmlrhdqn.tistory.com/231#entry231comment</comments>
      <pubDate>Tue, 18 Jul 2023 09:42:25 +0900</pubDate>
    </item>
    <item>
      <title>67-2</title>
      <link>https://qldfhrdmlrhdqn.tistory.com/230</link>
      <description>&lt;pre id=&quot;code_1689573518469&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;package com.care.dbQuiz.member;

import java.util.ArrayList;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import com.care.dbQuiz.common.PageService;


@Service
public class MemberService {
	@Autowired private MemberMapper memberMapper;
	@Autowired private HttpSession session;
	
	public String loginProc(MemberDTO member) {
		if(member.getId() == null || member.getId().isEmpty()) {
			return &quot;아이디를 입력하세요.&quot;;
		}
		
		if(member.getPw() == null || member.getPw().isEmpty()) {
			return &quot;비밀번호를 입력하세요.&quot;;
		}
		
		MemberDTO result = memberMapper.loginProc(member.getId());
		if(result != null){
			BCryptPasswordEncoder bpe = new BCryptPasswordEncoder();
			
			 //raw:원본 , encode:암호값을 가져와서 해독한다
			if(bpe.matches(member.getPw(), result.getPw())) {
				session.setAttribute(&quot;id&quot;, result.getId());
				session.setAttribute(&quot;userName&quot;, result.getUserName());

				
				session.setAttribute(&quot;address&quot;, result.getAddress());
				session.setAttribute(&quot;mobile&quot;, result.getMobile());
				return &quot;로그인 성공&quot;;
			}
			
		}
		
		return &quot;아이디/비밀번호를 확인 후 다시 시도하세요.&quot;;
	}

	public String registerProc(MemberDTO member, String confirm) {
		if(member.getId() == null || member.getId().isEmpty()) {
			return &quot;아이디를 입력하세요.&quot;;
		}
		
		if(member.getPw() == null || member.getPw().isEmpty()) {
			return &quot;비밀번호를 입력하세요.&quot;;
		}
		
		if(member.getPw().equals(confirm) == false) {
			return &quot;두 비밀번호를 일치하여 입력하세요.&quot;;
		}
		
		if(member.getUserName() == null || member.getUserName().isEmpty()) {
			return &quot;이름을 입력하세요.&quot;;
		}
		
		
		
//		System.out.println(&quot;평문 비밀번호 : &quot;+member.getPw());
//		System.out.println(&quot;암호화된 비밀번호 : &quot;+crytPassword);
//		System.out.println(&quot;암호화된 비밀번호 길이 : &quot;+crytPassword.length());
		
		MemberDTO result = memberMapper.loginProc(member.getId());
		if(result == null) {
			BCryptPasswordEncoder bpe = new BCryptPasswordEncoder();
			String crytPassword = bpe.encode(member.getPw());
			member.setPw(crytPassword);
			memberMapper.registerProc(member);
			return &quot;회원 등록 완료&quot;;
		}
		
		return &quot;이미 가입된 아이디 입니다.&quot;;
	}

	public void memberInfo(String cp, String select, String search, Model model) {
		if(select == null){
			select = &quot;&quot;;
		}
		
		int currentPage = 1;
		try{
			currentPage = Integer.parseInt(cp);
		}catch(Exception e){
			currentPage = 1;
		}
		
		int pageBlock = 3; // 한 페이지에 보일 데이터의 수 
		int end = pageBlock * currentPage; // 테이블에서 가져올 마지막 행번호
		int begin = end - pageBlock + 1; // 테이블에서 가져올 시작 행번호
	
		ArrayList&amp;lt;MemberDTO&amp;gt; members = memberMapper.memberInfo(begin, end, select, search);
		int totalCount = memberMapper.count(select, search);
		String url = &quot;memberInfo?select=&quot;+select+&quot;&amp;amp;search=&quot;+search+&quot;&amp;amp;currentPage=&quot;;
		String result = PageService.printPage(url, currentPage, totalCount, pageBlock);
		
		model.addAttribute(&quot;members&quot;, members);
		model.addAttribute(&quot;result&quot;, result);
		model.addAttribute(&quot;currentPage&quot;, currentPage);
	}

	public MemberDTO userInfo(String id) {
		if(id == null || id.isEmpty()) {
			return null;
		}
		
		String sessionId = (String)session.getAttribute(&quot;id&quot;);
		if(sessionId.equals(id) == false &amp;amp;&amp;amp; sessionId.equals(&quot;admin&quot;) == false)
			return null;
		
//		MemberDTO result = memberMapper.loginProc(id);
		return memberMapper.loginProc(id);
	}

	public String updateProc(MemberDTO member, String confirm) {
		if(member.getPw() == null || member.getPw().isEmpty()) {
			return &quot;비밀번호를 입력하세요.&quot;;
		}
		
		if(member.getPw().equals(confirm) == false) {
			return &quot;두 비밀번호를 일치하여 입력하세요.&quot;;
		}
		
		if(member.getUserName() == null || member.getUserName().isEmpty()) {
			return &quot;이름을 입력하세요.&quot;;
		}
		BCryptPasswordEncoder bpe = new BCryptPasswordEncoder();
		String crytPassword = bpe.encode(member.getPw());
		member.setPw(crytPassword);
		int result = memberMapper.updateProc(member);
		if(result == 1)
			return &quot;회원 정보 수정 완료&quot;;
		return &quot;회원 정보 수정 실패&quot;;
	}

	public String deleteProc(String id, String pw, String confirmPw) {
		if(pw == null || pw.isEmpty()) {
			return &quot;비밀번호를 입력하세요.&quot;;
		}
		
		if(pw.equals(confirmPw) == false) {
			return &quot;두 비밀번호를 일치하여 입력하세요.&quot;;
		}
		
		MemberDTO member = memberMapper.loginProc(id);
		
		if(member != null) {
			BCryptPasswordEncoder bpe = new BCryptPasswordEncoder();
			if(bpe.matches(pw, member.getPw())) {
				memberMapper.delete(member.getId());
				session.invalidate();
				return &quot;회원 정보 삭제 완료&quot;;
			}
			
		}
		return &quot;비밀번호를 확인 후 다시 시도하세요.&quot;;
	}
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689573512037&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;package com.care.dbQuiz.member;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class MemberController {
	@Autowired private MemberService service;
	@Autowired private HttpSession session;
	
	@RequestMapping(&quot;index&quot;)
	public String index() {
		return &quot;member/index&quot;;
	}

	@RequestMapping(&quot;header&quot;)
	public String header() {
		return &quot;default/header&quot;;
	}
	@RequestMapping(&quot;main&quot;)
	public String main() {
		return &quot;default/main&quot;;
	}
	@RequestMapping(&quot;footer&quot;)
	public String footer() {
		return &quot;default/footer&quot;;
	}
	/* http://localhost:8086/dbQuiz/login */
	@GetMapping(&quot;login&quot;)
	public String login() {
		return &quot;member/login&quot;;
	}
	
	@PostMapping(&quot;loginProc&quot;)
	public String loginProc(MemberDTO member) {
		String result = service.loginProc(member);
		if(result.equals(&quot;로그인 성공&quot;)) {
			return &quot;redirect:index&quot;;
		}
		return &quot;member/login&quot;;
	}
	
	/* http://localhost:8086/dbQuiz/register */
	@GetMapping(&quot;register&quot;)
	public String register() {
		return &quot;member/register&quot;;
	}
	
	@PostMapping(&quot;registerProc&quot;)
	public String registerProc(MemberDTO member, String confirm) {
		String result = service.registerProc(member, confirm);
		if(result.equals(&quot;회원 등록 완료&quot;)) {
			return &quot;redirect:index&quot;;
		}
		return &quot;member/register&quot;;
	}
	
	@RequestMapping(&quot;memberInfo&quot;)
	public String memberInfo(
			@RequestParam(value=&quot;currentPage&quot;, required = false)String cp,
			String select, String search, Model model) {
		service.memberInfo(cp, select, search, model);
		return &quot;member/memberInfo&quot;;
	}
	
	@RequestMapping(&quot;userInfo&quot;)
	public String userInfo(String id, 
			@RequestParam(value=&quot;currentPage&quot;, required = false)String cp, 
			Model model) {
		
		if(session.getAttribute(&quot;id&quot;) == null ) {
			return &quot;redirect:login&quot;;
		}
		MemberDTO member = service.userInfo(id);
		if(member == null) {
			return &quot;redirect:memberInfo?currentPage=&quot;+cp;
		}
		model.addAttribute(&quot;userInfo&quot;, member);
		return &quot;member/userInfo&quot;;
	}
	
	@RequestMapping(&quot;logout&quot;)
	public String logout() {
		session.invalidate();
		return &quot;forward:index&quot;;
	}
	
	/* http://localhost:8086/dbQuiz/update */
	@GetMapping(&quot;update&quot;)
	public String update() {
		String id = (String)session.getAttribute(&quot;id&quot;);
		if(id == null || id.isEmpty()) {
			return &quot;redirect:login&quot;;
		}
		return &quot;member/update&quot;;
	}
	@PostMapping(&quot;updateProc&quot;)
	public String updateProc(MemberDTO member, String confirm) {
		String id = (String)session.getAttribute(&quot;id&quot;);
		if(id == null || id.isEmpty()) {
			return &quot;redirect:login&quot;;
		}
		member.setId(id);
		String result = service.updateProc(member, confirm);
		if(result.equals(&quot;회원 정보 수정 완료&quot;)) {
			return &quot;forward:logout&quot;;
		}
		return &quot;member/update&quot;;
	}
	
	
	/* http://localhost:8086/dbQuiz/delete */
	@GetMapping(&quot;delete&quot;)
	public String delete() {
		String id = (String)session.getAttribute(&quot;id&quot;);
		if(id == null || id.isEmpty()) {
			return &quot;redirect:login&quot;;
		}
		return &quot;member/delete&quot;;
	}
	
	@PostMapping(&quot;deleteProc&quot;)
	public String deleteProc(String pw, String confirmPw, Model model) {
		String id = (String)session.getAttribute(&quot;id&quot;);
		if(id == null || id.isEmpty()) {
			return &quot;redirect:login&quot;;
		}
		
		String result = service.deleteProc(id, pw, confirmPw);
		model.addAttribute(&quot;msg&quot;, result);
		if(result.equals(&quot;회원 정보 삭제 완료&quot;)) {
			return &quot;forward:logout&quot;;
		}
		return &quot;member/delete&quot;;
	}
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689573503949&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot;
    pageEncoding=&quot;UTF-8&quot;%&amp;gt;
&amp;lt;%@ taglib uri=&quot;http://java.sun.com/jsp/jstl/core&quot; prefix=&quot;c&quot;%&amp;gt;
&amp;lt;c:import url=&quot;/header&quot;&amp;gt;&amp;lt;/c:import&amp;gt;

&amp;lt;script src=&quot;//t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script&amp;gt;
    //본 예제에서는 도로명 주소 표기 방식에 대한 법령에 따라, 내려오는 데이터를 조합하여 올바른 주소를 구성하는 방법을 설명합니다.
    function execDaumPostcode() {
        new daum.Postcode({
            oncomplete: function(data) {
            	if(data.userSelectedType === 'R'){
            		document.getElementById('address').value= data.roadAddress;
            	}
            	else{
            		document.getElementById('address').value= data.jibunAddress;
            	}
            	document.getElementById('postcode').value= data.zonecode;
            	/*
	            	console.log(data.userSelectedType)
	            	console.log(data.jibunAddress)
	            	console.log(data.roadAddress)
	            	console.log(data.zonecode)
            	*/
            }
        }).open();
    }
&amp;lt;/script&amp;gt;

&amp;lt;div align=&quot;center&quot;&amp;gt;
	&amp;lt;h1&amp;gt;회원 등록&amp;lt;/h1&amp;gt;
	&amp;lt;table &amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;
	&amp;lt;form action=&quot;registerProc&quot; method=&quot;post&quot; id=&quot;f&quot;&amp;gt;
		&amp;lt;input type=&quot;text&quot; name=&quot;id&quot; placeholder=&quot;아이디&quot; id=&quot;id&quot;&amp;gt; (*필수 항목) &amp;lt;br&amp;gt;
		&amp;lt;input type=&quot;password&quot; name=&quot;pw&quot; placeholder=&quot;비밀번호&quot; id=&quot;pw&quot;&amp;gt;&amp;lt;br&amp;gt;
		&amp;lt;input type=&quot;password&quot; name=&quot;confirm&quot; placeholder=&quot;비밀번호 확인 &quot; id=&quot;confirm&quot;
		onchange=&quot;pwCheck()&quot;&amp;gt;
	
		&amp;lt;label id=&quot;label&quot; &amp;gt;&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
		&amp;lt;input type=&quot;text&quot; name=&quot;userName&quot; id=&quot;userName&quot; placeholder=&quot;이름&quot; &amp;gt;&amp;lt;br&amp;gt;
		
		&amp;lt;input type=&quot;text&quot; id=&quot;postcode&quot; name=&quot;postcode&quot; placeholder=&quot;우편번호&quot;&amp;gt;
		&amp;lt;input type=&quot;button&quot; onclick=&quot;execDaumPostcode()&quot; value=&quot;우편번호 찾기&quot;&amp;gt;&amp;lt;br&amp;gt;
		&amp;lt;input type=&quot;text&quot; id=&quot;address&quot; name=&quot;address&quot; placeholder=&quot;도로명주소&quot;&amp;gt;
		&amp;lt;span id=&quot;guide&quot; style=&quot;color:#999;display:none&quot;&amp;gt;&amp;lt;/span&amp;gt;
		&amp;lt;input type=&quot;text&quot; id=&quot;detailAddress&quot; name=&quot;detailAddress&quot; placeholder=&quot;상세주소&quot;&amp;gt;
	
		&amp;lt;input type=&quot;text&quot; name=&quot;mobile&quot; placeholder=&quot;전화번호&quot; &amp;gt;&amp;lt;br&amp;gt;
		&amp;lt;input type=&quot;button&quot; value=&quot;회원가입&quot; onclick=&quot;allCheck()&quot;&amp;gt;
		&amp;lt;input type=&quot;button&quot; value=&quot;취소&quot; onclick=&quot;location.href='index'&quot;&amp;gt;&amp;lt;br&amp;gt;
	&amp;lt;/form&amp;gt;
	&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;c:import url=&quot;/footer&quot;&amp;gt;&amp;lt;/c:import&amp;gt;&lt;/code&gt;&lt;/pre&gt;</description>
      <category>프로그래밍/HTML</category>
      <author>빙록</author>
      <guid isPermaLink="true">https://qldfhrdmlrhdqn.tistory.com/230</guid>
      <comments>https://qldfhrdmlrhdqn.tistory.com/230#entry230comment</comments>
      <pubDate>Mon, 17 Jul 2023 14:58:49 +0900</pubDate>
    </item>
    <item>
      <title>67-1</title>
      <link>https://qldfhrdmlrhdqn.tistory.com/229</link>
      <description>&lt;pre id=&quot;code_1689554641613&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot;
    pageEncoding=&quot;UTF-8&quot;%&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta charset=&quot;UTF-8&quot;&amp;gt;
&amp;lt;title&amp;gt;quiz&amp;lt;/title&amp;gt;
&amp;lt;script&amp;gt;
	var xhr;
	function send(){
		
		xhr = new XMLHttpRequest();
		xhr.open('post', 'quiz')
		xhr.send(document.getElementById('title').value);
		//send 매서드에 값을 넣어준다
		xhr.onreadystatechange = resProc;

	}
	
	function resProc(){
		if(xhr.readyState === 4 &amp;amp;&amp;amp; xhr.status === 200){
			var resData = JSON.parse(xhr.responseText)
		
			var result = &quot;&quot;;
			for(i = 0; i &amp;lt; resData.length; i++){
				result += &quot;&amp;lt;tr&amp;gt;&quot;;
				result += &quot;&amp;lt;td&amp;gt;&quot; + resData[i].title + &quot;&amp;lt;/td&amp;gt;&quot;;
				result += &quot;&amp;lt;td&amp;gt;&quot; + resData[i].artist + &quot;&amp;lt;/td&amp;gt;&quot;;
				result += &quot;&amp;lt;td&amp;gt;&quot; + resData[i].price + &quot;&amp;lt;/td&amp;gt;&quot;;
				result += &quot;&amp;lt;/tr&amp;gt;&quot;;
			}
			
			document.getElementById('tbody').innerHTML = result;
			
		}
	}
&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body onload=&quot;send()&quot;&amp;gt;
	&amp;lt;input type=&quot;text&quot; id=&quot;title&quot; onkeyup=&quot;send()&quot;&amp;gt; 
	&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
	&amp;lt;table border=1&amp;gt;
		&amp;lt;tr&amp;gt;
			&amp;lt;th&amp;gt;제목&amp;lt;/th&amp;gt;
			&amp;lt;th&amp;gt;아티스트&amp;lt;/th&amp;gt;
			&amp;lt;th&amp;gt;가격&amp;lt;/th&amp;gt;
		&amp;lt;/tr&amp;gt;
		&amp;lt;tbody id=&quot;tbody&quot;&amp;gt;&amp;lt;/tbody&amp;gt;
	&amp;lt;/table&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;------------------------&lt;/p&gt;
&lt;pre id=&quot;code_1689554541644&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;package com.care.ajaxBasic;

import java.util.List;

import org.springframework.stereotype.Repository;

@Repository
public interface AjaxMapper {

	String exists(String id);

	int jsonInsert(AjaxVO ajax);

	void jsonDelete();

	List&amp;lt;AjaxVO&amp;gt; ex6();

	List&amp;lt;AjaxVO&amp;gt; serach(String title);

}&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689554532364&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;@GetMapping(&quot;quiz&quot;)
	public void quizGet() {}
	
	@ResponseBody
	@PostMapping(value=&quot;quiz&quot;, produces = &quot;application/json; charset=UTF-8&quot;)
	public List&amp;lt;AjaxVO&amp;gt; quizPost(@RequestBody(required = false)String title) {
		/*
		 * 첫 화면 또는 input에 아무것도 입력이 안되어 있으면 모든 데이터 출력하기.
		 * input 에 입력한 글자를 포함한 데이터가 있으면 모두 출력하기.
		 */
		System.out.println(&quot;quizPost() 호출함.&quot;+title);
		return service.search(title);
		
	}&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689554512628&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot;
    pageEncoding=&quot;UTF-8&quot;%&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta charset=&quot;UTF-8&quot;&amp;gt;
&amp;lt;title&amp;gt;quiz&amp;lt;/title&amp;gt;
&amp;lt;script&amp;gt;
	var xhr;
	function send(){
		xhr = new XMLHttpRequest();
		xhr.open('post', 'quiz')
		xhr.send();
		xhr.onreadystatechange = resProc;

	}
	
	function resProc(){
		if(xhr.readyState === 4 &amp;amp;&amp;amp; xhr.status === 200){
			var resData = JSON.parse(xhr.responseText)
		
			var result = &quot;&quot;;
			for(i = 0; i &amp;lt; resData.length; i++){
				result += &quot;&amp;lt;tr&amp;gt;&quot;;
				result += &quot;&amp;lt;td&amp;gt;&quot; + resData[i].title + &quot;&amp;lt;/td&amp;gt;&quot;;
				result += &quot;&amp;lt;td&amp;gt;&quot; + resData[i].artist + &quot;&amp;lt;/td&amp;gt;&quot;;
				result += &quot;&amp;lt;td&amp;gt;&quot; + resData[i].price + &quot;&amp;lt;/td&amp;gt;&quot;;
				result += &quot;&amp;lt;/tr&amp;gt;&quot;;
			}
			
			document.getElementById('tbody').innerHTML = result;
			
		}
	}
&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body onload=&quot;send()&quot;&amp;gt;
	&amp;lt;input type=&quot;text&quot; id=&quot;title&quot; onkeyup=&quot;send()&quot;&amp;gt; 
	&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
	&amp;lt;table border=1&amp;gt;
		&amp;lt;tr&amp;gt;
			&amp;lt;th&amp;gt;제목&amp;lt;/th&amp;gt;
			&amp;lt;th&amp;gt;아티스트&amp;lt;/th&amp;gt;
			&amp;lt;th&amp;gt;가격&amp;lt;/th&amp;gt;
		&amp;lt;/tr&amp;gt;
		&amp;lt;tbody id=&quot;tbody&quot;&amp;gt;&amp;lt;/tbody&amp;gt;
	&amp;lt;/table&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;/pre&gt;</description>
      <category>프로그래밍/HTML</category>
      <author>빙록</author>
      <guid isPermaLink="true">https://qldfhrdmlrhdqn.tistory.com/229</guid>
      <comments>https://qldfhrdmlrhdqn.tistory.com/229#entry229comment</comments>
      <pubDate>Mon, 17 Jul 2023 10:19:24 +0900</pubDate>
    </item>
    <item>
      <title>66-4</title>
      <link>https://qldfhrdmlrhdqn.tistory.com/228</link>
      <description>&lt;pre id=&quot;code_1689316015459&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;!DOCTYPE mapper
  PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
  &quot;https://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;&amp;gt;
  
&amp;lt;mapper namespace=&quot;com.care.ajaxBasic.AjaxMapper&quot;&amp;gt;
	&amp;lt;select id=&quot;exists&quot;&amp;gt;
		SELECT id FROM session_quiz WHERE id=#{id}
	&amp;lt;/select&amp;gt;
	
	
	
	&amp;lt;insert id=&quot;jsonInsert&quot; parameterType=&quot;com.care.ajaxBasic.AjaxVO&quot;&amp;gt;
		insert into json_table values (#{title},#{artist},#{price})
	&amp;lt;/insert&amp;gt;
	
	&amp;lt;delete id=&quot;jsonDelete&quot;&amp;gt;
		delete from json_table
	&amp;lt;/delete&amp;gt;
&amp;lt;/mapper&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689316008659&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;package com.care.ajaxBasic;

import java.util.List;

import org.springframework.stereotype.Repository;

@Repository
public interface AjaxMapper {

	String exists(String id);

	int jsonInsert(AjaxVO ajax);

	void jsonDelete();

}&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689315994507&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;public String jsonInsert() {
		/*
		 * json 파일의 데이터를 읽어와서
		 * mapper.jsonInset 를 호출
		 * json_table데이블에 jsonExam2 파일 입력
		 * json_table테이블 title artist oruce varchar2구성
		 * */
		
		ClassPathResource cpr = new ClassPathResource(&quot;jsonExam2.json&quot;);
		List&amp;lt;AjaxVO&amp;gt; lists = null;
		try {
			File file = cpr.getFile();
			//Json array List 변환
			ObjectMapper mapper = new ObjectMapper();

			lists = mapper.readValue(file, new TypeReference&amp;lt;List&amp;lt;AjaxVO&amp;gt;&amp;gt;() {});
			
			System.out.println( (new TypeReference&amp;lt;List&amp;lt;AjaxVO&amp;gt;&amp;gt;() {}).getType() );
			//java.util.List&amp;lt;com.care.ajaxBasic.AjaxVO&amp;gt;
			//TypeReference를 사용하는 이유 : 제너릭을 사용하는 클래스의 자료형을 얻고 싶을 때
			
			
			} catch (IOException e) {
			
			e.printStackTrace();
			}
			mapper.jsonDelete(); //초기화
			for(AjaxVO ajax : lists) {
				int result = mapper.jsonInsert(ajax);
				if(result == 0)
					return &quot;오류&quot;;
				
			}
				
		return &quot;모든 데이터가 입력되었습니다&quot;;
	}&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689315983124&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;@ResponseBody
	@GetMapping(value=&quot;jsonInsert&quot;,produces = &quot;application/json; charset=UTF-8&quot;)
	public String jsonInsert() {
		
		String msg = service.jsonInsert();
		return msg;
		
	}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;----------&lt;/p&gt;
&lt;pre id=&quot;code_1689314608029&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;public String jsonInsert(List&amp;lt;AjaxVO&amp;gt;) {
		/*
		 * json 파일의 데이터를 읽어와서
		 * mapper.jsonInset 를 호출
		 * json_table데이블에 jsonExam2 파일 입력
		 * json_table테이블 title artist oruce varchar2구성
		 * */
		
		
		mapper.jsonInsert(result);
		return &quot;모든 데이터가 입력되었습니다&quot;;
	}&lt;/code&gt;&lt;/pre&gt;
&lt;pre id=&quot;code_1689314578831&quot; class=&quot;java&quot; data-ke-language=&quot;java&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;@RequestMapping(value=&quot;ex6&quot;,produces = &quot;application/json; charset=UTF-8&quot;)
	public List&amp;lt;AjaxVO&amp;gt; ex6Post() {
		ClassPathResource cpr = new ClassPathResource(&quot;jsonExam2.json&quot;);
		List&amp;lt;AjaxVO&amp;gt; lists = null;
		try {
			File file = cpr.getFile();
			//Json array List 변환
			ObjectMapper mapper = new ObjectMapper();

			lists = mapper.readValue(file, new TypeReference&amp;lt;List&amp;lt;AjaxVO&amp;gt;&amp;gt;() {});
			
			
			Servicece.jsonInsert(lists);
			
		} catch (IOException e) {
			
			e.printStackTrace();
		}
		return lists;
	
	}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>프로그래밍/HTML</category>
      <author>빙록</author>
      <guid isPermaLink="true">https://qldfhrdmlrhdqn.tistory.com/228</guid>
      <comments>https://qldfhrdmlrhdqn.tistory.com/228#entry228comment</comments>
      <pubDate>Fri, 14 Jul 2023 15:26:57 +0900</pubDate>
    </item>
  </channel>
</rss>