-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-spring.html
More file actions
1086 lines (658 loc) · 56.7 KB
/
Copy pathstart-spring.html
File metadata and controls
1086 lines (658 loc) · 56.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<!-- Document Settings -->
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Base Meta -->
<!-- dynamically fixing the title for tag/author pages -->
<title>Spring 프레임워크를 이용한 프로젝트 생성 (with STS, JSP)</title>
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Styles'n'Scripts -->
<link rel="stylesheet" type="text/css" href="/assets/built/screen.css" />
<link rel="stylesheet" type="text/css" href="/assets/built/screen.edited.css" />
<link rel="stylesheet" type="text/css" href="/assets/built/syntax.css" />
<!-- custom.css -->
<link rel="stylesheet" type="text/css" href="/assets/built/custom.css" />
<!-- Font Awesome -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- 웹폰트 추가 -->
<link rel="stylesheet" href="https://fonts.googleapis.com/earlyaccess/nanumgothic.css">
<!-- highlight.js -->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css">
<style>.hljs { background: none; }</style>
<!--[if IE]>
<style>
p, ol, ul{
width: 100%;
}
blockquote{
width: 100%;
}
</style>
<![endif]-->
<!-- This tag outputs SEO meta+structured data and other important settings -->
<meta name="description" content="기술 블로그" />
<link rel="shortcut icon" href="https://simplehanlab.github.io/assets/built/images/favicon.jpg" type="image/png" />
<link rel="canonical" href="https://simplehanlab.github.io/start-spring" />
<meta name="referrer" content="no-referrer-when-downgrade" />
<!--title below is coming from _includes/dynamic_title-->
<meta property="og:site_name" content="SimpleHan Lab" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Spring 프레임워크를 이용한 프로젝트 생성 (with STS, JSP)" />
<meta property="og:description" content="STS (Spring Tool Suite) 받기 Spring 프레임워크를 이용하여 프로젝트를 만들기위해 IDE를 정해야하는데, 여러가지 IDE가 있겠지만 Spring 프로젝트 제작시에는 STS를 이용하는게 좋은 방법이라 생각된다. 일단 이클립스 기반이기 때문에 이클립스로 JAVA 프로젝트를 개발하던 개발자들도 익숙하게 사용이 가능하고, 무료로 이용할 수 있다. Spring 팀에서 제작했기 때문에 Spring 프레임워크와 호환도 좋다. 이름부터가 Spring Tool" />
<meta property="og:url" content="https://simplehanlab.github.io/start-spring" />
<meta property="og:image" content="https://simplehanlab.github.io/assets/built/images/start-spring/spring-logo.png" />
<meta property="article:publisher" content="https://www.facebook.com/" />
<meta property="article:author" content="https://www.facebook.com/" />
<meta property="article:published_time" content="2020-02-04T14:00:00+00:00" />
<meta property="article:modified_time" content="2020-02-04T14:00:00+00:00" />
<meta property="article:tag" content="Spring" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Spring 프레임워크를 이용한 프로젝트 생성 (with STS, JSP)" />
<meta name="twitter:description" content="STS (Spring Tool Suite) 받기 Spring 프레임워크를 이용하여 프로젝트를 만들기위해 IDE를 정해야하는데, 여러가지 IDE가 있겠지만 Spring 프로젝트 제작시에는 STS를 이용하는게 좋은 방법이라 생각된다. 일단 이클립스 기반이기 때문에 이클립스로 JAVA 프로젝트를 개발하던 개발자들도 익숙하게 사용이 가능하고, 무료로 이용할 수 있다. Spring 팀에서 제작했기 때문에 Spring 프레임워크와 호환도 좋다. 이름부터가 Spring Tool" />
<meta name="twitter:url" content="https://simplehanlab.github.io/" />
<meta name="twitter:image" content="https://simplehanlab.github.io/assets/built/images/start-spring/spring-logo.png" />
<meta name="twitter:label1" content="Written by" />
<meta name="twitter:data1" content="SimpleHan Lab" />
<meta name="twitter:label2" content="Filed under" />
<meta name="twitter:data2" content="Spring" />
<meta name="twitter:site" content="@" />
<meta name="twitter:creator" content="@" />
<meta property="og:image:width" content="1400" />
<meta property="og:image:height" content="933" />
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Website",
"publisher": {
"@type": "Organization",
"name": "SimpleHan Lab",
"logo": "https://simplehanlab.github.io/"
},
"url": "https://simplehanlab.github.io/start-spring",
"image": {
"@type": "ImageObject",
"url": "https://simplehanlab.github.io/assets/built/images/start-spring/spring-logo.png",
"width": 2000,
"height": 666
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://simplehanlab.github.io/start-spring"
},
"description": "STS (Spring Tool Suite) 받기 Spring 프레임워크를 이용하여 프로젝트를 만들기위해 IDE를 정해야하는데, 여러가지 IDE가 있겠지만 Spring 프로젝트 제작시에는 STS를 이용하는게 좋은 방법이라 생각된다. 일단 이클립스 기반이기 때문에 이클립스로 JAVA 프로젝트를 개발하던 개발자들도 익숙하게 사용이 가능하고, 무료로 이용할 수 있다. Spring 팀에서 제작했기 때문에 Spring 프레임워크와 호환도 좋다. 이름부터가 Spring Tool"
}
</script>
<!-- <script type="text/javascript" src="https://demo.ghost.io/public/ghost-sdk.min.js?v=724281a32e"></script>
<script type="text/javascript">
ghost.init({
clientId: "ghost-frontend",
clientSecret: "f84a07a72b17"
});
</script> -->
<meta name="generator" content="Jekyll 3.6.2" />
<link rel="alternate" type="application/rss+xml" title="Spring 프레임워크를 이용한 프로젝트 생성 (with STS, JSP)" href="/feed.xml" />
</head>
<body class="post-template">
<div class="site-wrapper">
<!-- All the main content gets inserted here, index.hbs, post.hbs, etc -->
<!-- default -->
<!-- The tag above means: insert everything in this file
into the {body} of the default.hbs template -->
<header class="site-header outer">
<div class="inner">
<nav class="site-nav">
<div class="site-nav-left">
<a class="site-nav-logo" href="https://simplehanlab.github.io/">SimpleHan Lab</a>
<ul class="nav" role="menu">
<li class="nav-about" role="menuitem"><a href="/about/">About</a></li>
<li class="nav-jekyll" role="menuitem"><a href="/category/react/">react</a></li>
<li class="nav-python" role="menuitem"><a href="/category/spring/">spring</a></li>
<li class="nav-java" role="menuitem"><a href="/category/ios/">ios</a></li>
<li class="nav-jekyll" role="menuitem"><a href="/category/jekyll/">jekyll</a></li>
<li class="nav-python" role="menuitem"><a href="/category/minimal-mistakes/">minimal-mistakes</a></li>
<li class="nav-python" role="menuitem"><a href="/category/ssl/">ssl</a></li>
<li class="nav-python" role="menuitem"><a href="/category/tensorflow/">tensorflow</a></li>
<li class="nav-python" role="menuitem"><a href="/category/ssh/">ssh</a></li>
<li class="nav-archive" role="menuitem">
<a href="/archive.html">All Posts</a>
</li>
<li class="nav-archive" role="menuitem">
<a href="/categories.html">카테고리별 Posts</a>
</li>
<li class="nav-archive" role="menuitem">
<a href="/author_archive.html">Tag별 Posts</a>
</li>
</ul>
</div>
<div class="site-nav-right">
<div class="social-links">
</div>
<a class="subscribe-button" href="#subscribe">Search</a>
</div>
</nav>
</div>
</header>
<!-- Everything inside the #post tags pulls data from the post -->
<!-- #post -->
<main id="site-main" class="site-main outer" role="main">
<div class="inner">
<article class="post-full tag-spring tag-sts tag-jsp ">
<header class="post-full-header">
<section class="post-full-meta">
<time class="post-full-meta-date" datetime=" 4 February 2020"> 4 February 2020</time>
<span class="date-divider">/</span>
<a href='/category/spring/'>SPRING</a>
</section>
<h1 class="post-full-title">Spring 프레임워크를 이용한 프로젝트 생성 (with STS, JSP)</h1>
</header>
<!--
<figure class="post-full-image" style="background-image: url(/assets/built/images/start-spring/spring-logo.png)">
</figure>
-->
<section class="post-full-content">
<div class="kg-card-markdown">
<h2 id="sts-spring-tool-suite-받기">STS (Spring Tool Suite) 받기</h2>
<p>Spring 프레임워크를 이용하여 프로젝트를 만들기위해 IDE를 정해야하는데, 여러가지 IDE가 있겠지만 Spring 프로젝트 제작시에는 STS를 이용하는게 좋은 방법이라 생각된다. 일단 이클립스 기반이기 때문에 이클립스로 JAVA 프로젝트를 개발하던 개발자들도 익숙하게 사용이 가능하고, 무료로 이용할 수 있다. Spring 팀에서 제작했기 때문에 Spring 프레임워크와 호환도 좋다. 이름부터가 Spring Tool Suite 이니..</p>
<p>그 외에 Spring 팀에서 제공하는 IDE가 더 있는데 Visual Studio Code 기반인 IDE와 Theia 기반인 IDE가 있다. 하지만 본 포스트에서는 STS만 다룬다.</p>
<p>STS를 받기 위해선 STS 사이트에 접속해야한다. 아래 주소를 통해 접속할 수 있다.</p>
<p><a href="https://spring.io/tools">Spring Tools</a></p>
<p>STS 사이트에 접속하면 아래 사진과 같이 IDE 다운로드 링크가 있으니 필요한 걸 받으면 된다. 본 포스트는 Windows 버전으로 진행한다. 버전은 4.5.1.RELEASE 버전으로 진행한다.</p>
<p><img src="\assets\built\images\start-spring\start-spring-1.JPG" alt="start-spring-1" /></p>
<p>Windows 버전을 다운받으면 jar 파일을 내려받게 된다. 이 jar파일의 압축을 풀면 <strong>contents</strong> 폴더가 나오게 되는데 이 안에 STS가 있다.</p>
<h2 id="spring-프로젝트-생성">Spring 프로젝트 생성</h2>
<p>다운받은 STS를 실행하면 아래와 같이 뜬다.</p>
<p><img src="\assets\built\images\start-spring\start-spring-2.JPG" alt="start-spring-2" /></p>
<p>좌측 Package Explorer 창에서 <strong>Create new Spring Starter Project</strong>를 클릭하면 Spring 프로젝트의 생성을 도와주는 프롬프트가 나오게 된다.</p>
<p><img src="\assets\built\images\start-spring\start-spring-3.JPG" alt="start-spring-3" /></p>
<p><a href="https://start.spring.io">https://start.spring.io</a> 에서 프로젝트 생성에 필요한 정보를 받아올 수 있다. Spring 프로젝트는 Web상에서 생성할 수도 있는데 해당 링크에 들어가서 필요한 정보를 입력, 체크한 뒤 Generate를 하면 프로젝트를 내려받을 수가 있다. 궁금하면 링크에 접속해보자.</p>
<p>필요한 정보를 입력한 뒤 Next를 클릭하자.</p>
<p><img src="\assets\built\images\start-spring\start-spring-4.JPG" alt="start-spring-4" /></p>
<p>Next를 입력하면 Spring에서 제공하는 서비스 모듈을 선택하여 프로젝트 생성 시 같이 포함하여 생성할 수 있다. 여기서 필요한 모듈을 선택하면 되는데, 본 포스트에서는 아래와 같이 Web의 Spring Web 항목만 체크하여 만들었다.</p>
<p><img src="\assets\built\images\start-spring\start-spring-5.JPG" alt="start-spring-5" /></p>
<p>필요한 모듈을 모두 체크하였으면 <strong>Finish</strong>버튼을 클릭하여 프로젝트를 생성한다.</p>
<p><img src="\assets\built\images\start-spring\start-spring-6.JPG" alt="start-spring-6" /></p>
<p>프로젝트가 생성되면 구조는 위의 이미지와 같다.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>my-project
├── src
| ├── main
| | ├── java <span class="c"># JAVA 파일</span>
| | └── resources <span class="c"># 정적 파일 (css, js, image, properties 등등)</span>
| └── <span class="nb">test</span>
| └── java <span class="c"># 테스트 용 JAVA 파일 (JUnit 등)</span>
├── JRE System Library <span class="c"># JRE</span>
├── Maven Dependencies <span class="c"># Maven 의존 모듈</span>
├── target <span class="c"># Build 결과물 보관 장소</span>
├── HELP.md <span class="c"># Spring 프로젝트 도움말 및 가이드</span>
├── mvnw <span class="c"># Maven Wrapper 스크립트</span>
├── mvnw.cmd <span class="c"># Maven Wrapper 스크립트의 배치 버전</span>
└── pom.xml <span class="c"># Maven 빌드 옵션 설정 파일</span>
</code></pre></div></div>
<p><em>(위의 구조는 폴더 구조가 아닌 Package Explorer에서 표출해주는 구조이다.)</em></p>
<h2 id="웹페이지-생성-및-접속해보기">웹페이지 생성 및 접속해보기</h2>
<p>예전에 이클립스, 전자정부 프레임워크, 스프링 프레임워크를 이용하여 개발할때 서버를 띄우기 위해서 톰캣을 같이 설치하여 톰캣으로 서버를 띄워줘야 했으나, 요즘 스프링 프레임워크는 스프링부트의 내장톰캣을 이용하여 서버를 띄울 수 있기 때문에 별도로 톰캣을 설치할 필요가 없다.</p>
<p><em>(운영환경이라면 톰캣의 커스터마이징이 필요할 수 있기 때문에 톰캣 설치를 추천한다.)</em></p>
<p>다만 스프링부트는 기본적으로 JSP를 지원하지 않기 때문에 JSP를 사용하기 위해선 별도로 메이븐을 통해 모듈을 받아야 한다. 당장에 필요한 모듈은 JSP를 구동시켜주는 내장톰캣 모듈과 JSTL을 지원해주는 JSTL 모듈이기 때문에 해당 모듈들을 <strong>pom.xml</strong>에 지정해주자.</p>
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><dependency></span>
<span class="nt"><groupId></span>javax.servlet<span class="nt"></groupId></span>
<span class="nt"><artifactId></span>jstl<span class="nt"></artifactId></span>
<span class="nt"></dependency></span>
<span class="nt"><dependency></span>
<span class="nt"><groupId></span>org.apache.tomcat.embed<span class="nt"></groupId></span>
<span class="nt"><artifactId></span>tomcat-embed-jasper<span class="nt"></artifactId></span>
<span class="nt"></dependency></span>
</code></pre></div></div>
<p>모듈 추가가 완료됬다면 다음으로 java 파일을 추가해보자. MVC 패턴을 적용하여 페이지를 만들 예정이다. 그렇기 때문에 일단 Controller를 만들어준다. 기본 생성된 프로젝트는 아래 이미지와 같이 스프링부트 기본 java 파일만 있다.</p>
<p><img src="\assets\built\images\start-spring\start-spring-7.JPG" alt="start-spring-7" /></p>
<p>여기에 패키지를 추가하고 Controller를 추가해보자. 패키지는 com.example.demo.main으로 만들고, 그 아래에 com.example.demo.main.controller 패키지를 하나 더 추가한 뒤 해당 패키지에 controller를 만든다. 아래 이미지를 보자. <em>(controller 패키지는 web 패키지로 사용하는 경우도 있다. // com.example.demo.main.web)</em></p>
<p><img src="\assets\built\images\start-spring\start-spring-8.JPG" alt="start-spring-8" /></p>
<p>MainController.java는 아직 아무 내용도 없다. 이제 이 java 파일이 controller라는 명시를 어노테이션을 통해서 지정해준 뒤, 루트(/) 주소에 View를 지정하자.</p>
<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">package</span> <span class="nn">com.example.demo.main.controller</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.springframework.stereotype.Controller</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.springframework.web.bind.annotation.RequestMapping</span><span class="o">;</span>
<span class="nd">@Controller</span> <span class="c1">// Controller 어노테이션을 통해 이제부터 이 java 파일은 Controller 역할을 수행한다.</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="nc">MainController</span> <span class="o">{</span>
<span class="nd">@RequestMapping</span><span class="o">(</span><span class="n">value</span><span class="o">=</span><span class="s">"/"</span><span class="o">)</span> <span class="c1">// 컨트롤 할 URL을 지정해준다. URL의 path 부분을 작성해주면 된다.</span>
<span class="kd">public</span> <span class="nc">String</span> <span class="nf">main</span><span class="o">()</span> <span class="o">{</span>
<span class="k">return</span> <span class="s">"main"</span><span class="o">;</span> <span class="c1">// View의 폴더, 파일 이름을 문자열로 리턴해준다.</span>
<span class="o">}</span>
<span class="o">}</span>
</code></pre></div></div>
<p>주목할 부분은 <strong>@Controller</strong>, <strong>@RequestMapping</strong> 어노테이션들과 <strong>return 값의 문자열</strong>이다. 최신 스프링 프레임워크에서 Controller를 사용하고 싶다면 간단하게 @Controller 어노테이션을 class 위에 명시해주기만 하면 된다. 그리고 URL 라우팅은 메소드 위에 @RequestMapping 어노테이션을 통해 간단히 구현할 수 있다. <em>(class 위에 @RequestMapping 어노테이션을 명시하여 해당 Controller에 전체적으로 공통 Path를 지정해주는 방법도 있다.)</em></p>
<p>그리고 마지막으로 주목해야할 return 문자열은 View의 폴더, 이름등을 지정해주는데 그렇다면 이 View는 어느 위치에 추가하는 것이며, 파일의 기본 폴더나 확장자 등은 스프링에서 자동으로 처리해 주는 것일까?</p>
<p>어느정도 자동으로 처리해주는 부분이 있지만, 기본 폴더나 확장자 등 prefix와 suffix는 따로 잡아줘야 한다. 이를 application.properties 라는 설정 파일에서 잡아줄 수 있다. 이 파일은 아래 이미지와 같이 스프링 프로젝트 생성 시 src/main/resources 폴더 안에 자동으로 생성된다.</p>
<p><img src="\assets\built\images\start-spring\start-spring-9.JPG" alt="start-spring-9" /></p>
<p>이제 이 properties 파일을 열고 아래 두 줄을 추가한다.</p>
<div class="language-properties highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="py">spring.mvc.view.prefix</span><span class="p">=</span><span class="s">/WEB-INF/jsp/</span>
<span class="py">spring.mvc.view.suffix</span><span class="p">=</span><span class="s">.jsp</span>
</code></pre></div></div>
<p>prefix는 controller에서 return된 문자열의 앞에 붙는 문자이고, suffix는 뒤에 붙는 문자이다. 위의 controller에서 main을 리턴하면 최종적으로 <strong>/WEB-INF/jsp/main.jsp</strong> 문자열이 완성되는 것이다.</p>
<p>하지만 프로젝트 어딜 찾아봐도 WEB-INF 폴더는 보이지 않는데, 이 폴더는 직접 만들어줘야 한다. 그 경로는 src/main/webapp 의 아래인데, main 폴더를 보면 webapp 폴더도 보이지 않는다. 그래서 webapp 폴더도 직접 만들어줘야 한다. <em>(위에서 View의 폴더 지정 등을 어느정도 자동으로 처리해주는 부분이 있다고 했는데 이 webapp 폴더가 그것이다. 기본적으로 내장 톰캣을 사용한 환경이기 때문에 webapp 폴더를 기본 폴더로 간주하고, 이를 prefix 등에 지정할 필요가 없다.)</em></p>
<p>properties 파일에 위 두줄을 추가했으면 이제 jsp 파일을 추가해주자. 아래 이미지처럼 추가해주면 된다.</p>
<p><img src="\assets\built\images\start-spring\start-spring-10.JPG" alt="start-spring-10" /></p>
<p>이 jsp 파일의 body안에 <strong>Hello world!</strong> 라고 작성해보자. 아래 코드를 참조하자.</p>
<div class="language-jsp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><%@ page </span><span class="na">language=</span><span class="s">"java"</span><span class="na"> contentType=</span><span class="s">"text/html; charset=EUC-KR"</span><span class="na"> pageEncoding=</span><span class="s">"EUC-KR"</span><span class="nt">%></span>
<span class="cp"><!DOCTYPE html></span>
<span class="nt"><html></span>
<span class="nt"><head></span>
<span class="nt"><meta</span> <span class="na">charset=</span><span class="s">"EUC-KR"</span><span class="nt">></span>
<span class="nt"><title></span>Insert title here<span class="nt"></title></span>
<span class="nt"></head></span>
<span class="nt"><body></span>
Hello world!
<span class="nt"></body></span>
<span class="nt"></html></span>
</code></pre></div></div>
<p>이제 이 페이지를 브라우저에서 띄워보자. STS를 따로 건드리지 않았다면 좌측 하단에 <strong>Boot Dashboard</strong>가 있다. <em>(만약 없다면 위에 Window > Show View > Other를 클릭하여 Boot Dashboard를 누르면 된다.)</em></p>
<p>이 Boot Dashboard를 보면 local 항목이 있을텐데 그 안에 내 프로젝트가 있다. 내 프로젝트를 선택한 뒤 그 위의 실행 혹은 디버그 버튼을 클릭하여 프로젝트를 실행하자. 아래 이미지를 참조</p>
<p><img src="\assets\built\images\start-spring\start-spring-11.JPG" alt="start-spring-11" /></p>
<p>실행이 완료되면 몇번 포트로 실행이 됬는지 콘솔에 출력된다. 아래 이미지 참조</p>
<p><img src="\assets\built\images\start-spring\start-spring-12.JPG" alt="start-spring-12" /></p>
<p>포트를 지정하지 않았다면 기본으로 8080포트에 서버가 뜨게 된다. <em>(포트 변경은 본 포스트 아래쪽 참조)</em></p>
<p>이제 사용하는 브라우저에서 http://localhost:8080에 접속해보자. 아래 이미지처럼 Hello world!가 화면에 찍히면 성공!</p>
<p><img src="\assets\built\images\start-spring\start-spring-13.JPG" alt="start-spring-13" /></p>
<h2 id="간단하게-model-추가해보기">간단하게 Model 추가해보기</h2>
<p>이제 기본 main.jsp 페이지에서 이름과 나이를 출력하는 간단한 model을 만들어보자. com.example.demo.main.vo 패키지를 추가한 뒤 Person.java 파일을 추가해주자. <em>(vo 패키지는 dto 등으로도 쓸 수 있다. // 더 세세하게 들어가면 dto와 vo의 차이점이 있지만 본 포스팅에서는 그렇게까지 나누지 않을 예정이고 그냥 편의상 vo로 사용)</em></p>
<p><img src="\assets\built\images\start-spring\start-spring-14.JPG" alt="start-spring-14" /></p>
<p>Person.java 안의 내용은 아래처럼 작성해주자.</p>
<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">package</span> <span class="nn">com.example.demo.main.vo</span><span class="o">;</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="nc">Person</span> <span class="o">{</span>
<span class="kd">private</span> <span class="nc">String</span> <span class="n">name</span> <span class="o">=</span> <span class="s">"Simple"</span><span class="o">;</span>
<span class="kd">private</span> <span class="kt">int</span> <span class="n">age</span> <span class="o">=</span> <span class="mi">20</span><span class="o">;</span>
<span class="kd">public</span> <span class="nc">String</span> <span class="nf">getName</span><span class="o">()</span> <span class="o">{</span>
<span class="k">return</span> <span class="n">name</span><span class="o">;</span>
<span class="o">}</span>
<span class="kd">public</span> <span class="kt">int</span> <span class="nf">getAge</span><span class="o">()</span> <span class="o">{</span>
<span class="k">return</span> <span class="n">age</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
</code></pre></div></div>
<p>이제 jsp에서 name과 age를 출력해보자.</p>
<p><strong><em>(지금은 간단한 구현을 위해 속성에 값을 직접 할당했지만 실 개발에선 값을 직접 할당하지 않고 거의 대부분의 경우에 Setter를 통해 값을 지정하고 조회한다. 추가로 Lombok등을 이용하여 Getter, Setter의 코드를 줄이는 등의 방법도 있다.)</em></strong></p>
<p>다시 MainController.java 파일을 열어서 아래와 같이 코드를 수정해주자.</p>
<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">package</span> <span class="nn">com.example.demo.main.controller</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.springframework.stereotype.Controller</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.springframework.ui.Model</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.springframework.web.bind.annotation.RequestMapping</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">com.example.demo.main.vo.Person</span><span class="o">;</span>
<span class="c1">// Controller 어노테이션을 통해 이제부터 이 java 파일은 Controller 역할을 수행한다.</span>
<span class="nd">@Controller</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="nc">MainController</span> <span class="o">{</span>
<span class="nd">@RequestMapping</span><span class="o">(</span><span class="n">value</span><span class="o">=</span><span class="s">"/"</span><span class="o">)</span> <span class="c1">// URL의 path 부분을 작성해주면 된다.</span>
<span class="kd">public</span> <span class="nc">String</span> <span class="nf">main</span><span class="o">(</span><span class="nc">Model</span> <span class="n">model</span><span class="o">)</span> <span class="o">{</span>
<span class="n">model</span><span class="o">.</span><span class="na">addAttribute</span><span class="o">(</span><span class="s">"person"</span><span class="o">,</span> <span class="k">new</span> <span class="nc">Person</span><span class="o">());</span> <span class="c1">// 모델 부여</span>
<span class="k">return</span> <span class="s">"main"</span><span class="o">;</span> <span class="c1">// View의 폴더, 파일 이름을 문자열로 리턴해준다.</span>
<span class="o">}</span>
<span class="o">}</span>
</code></pre></div></div>
<p>그 다음 main.jsp 파일을 열어서 아래와 같이 수정해주자.</p>
<div class="language-jsp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><%@ page </span><span class="na">language=</span><span class="s">"java"</span><span class="na"> contentType=</span><span class="s">"text/html; charset=EUC-KR"</span><span class="na"> pageEncoding=</span><span class="s">"EUC-KR"</span><span class="nt">%></span>
<span class="cp"><!DOCTYPE html></span>
<span class="nt"><html></span>
<span class="nt"><head></span>
<span class="nt"><meta</span> <span class="na">charset=</span><span class="s">"EUC-KR"</span><span class="nt">></span>
<span class="nt"><title></span>Insert title here<span class="nt"></title></span>
<span class="nt"></head></span>
<span class="nt"><body></span>
Hello world!<span class="nt"><br/></span>
My name is ${person.name}<span class="nt"><br/></span>
I'm ${person.age} years old<span class="nt"><br/></span>
<span class="nt"></body></span>
<span class="nt"></html></span>
</code></pre></div></div>
<p>그 다음 서버를 재시작하여 브라우저에 아래와 같이 잘 나오는 지 확인해보자.</p>
<p><img src="\assets\built\images\start-spring\start-spring-15.JPG" alt="start-spring-15" /></p>
<h2 id="restcontroller-사용해보기">RestController 사용해보기</h2>
<p>요즘은 HTTP 프로토콜을 이용한 API 사용에 Restful API를 많이 사용한다. 스프링에서도 이 Restful API 개발을 지원하는데 이때 쓰는 것이 @RestController 어노테이션이다. 위에서 작성한 Person 객체를 JSON 형태로 응답해주는 간단한 RestController를 만들어보자.</p>
<p>일단 com.example.demo.main.controller 패키지 안에 MainRestController.java 파일을 추가한다.</p>
<p><img src="\assets\built\images\start-spring\start-spring-16.JPG" alt="start-spring-16" /></p>
<p>그 다음 MainRestController 안에 아래와 같이 작성해주자.</p>
<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">package</span> <span class="nn">com.example.demo.main.controller</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.springframework.web.bind.annotation.RequestMapping</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.springframework.web.bind.annotation.RequestMethod</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.springframework.web.bind.annotation.RestController</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">com.example.demo.main.vo.Person</span><span class="o">;</span>
<span class="c1">// RestController 어노테이션을 통해 이제부터 이 java 파일은 RestController 역할을 수행한다.</span>
<span class="nd">@RestController</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="nc">MainRestController</span> <span class="o">{</span>
<span class="nd">@RequestMapping</span><span class="o">(</span><span class="n">value</span><span class="o">=</span><span class="s">"/api"</span><span class="o">,</span> <span class="n">method</span><span class="o">=</span><span class="nc">RequestMethod</span><span class="o">.</span><span class="na">GET</span><span class="o">)</span> <span class="c1">// URL의 path와 HTTP method를 작성한다.</span>
<span class="kd">public</span> <span class="nc">Person</span> <span class="nf">getPerson</span><span class="o">()</span> <span class="o">{</span>
<span class="k">return</span> <span class="k">new</span> <span class="nf">Person</span><span class="o">();</span> <span class="c1">// 객체형으로 응답하면 JSON 형태로 변환된다.</span>
<span class="o">}</span>
<span class="o">}</span>
</code></pre></div></div>
<p>그 다음 http://localhost:8080/api 로 접속하여 Person 객체를 제대로 반환해주는 지 확인한다.</p>
<p><img src="\assets\built\images\start-spring\start-spring-17.JPG" alt="start-spring-17" /></p>
<h2 id="추가-설정-port-변경">추가 설정: port 변경</h2>
<p>기본으로 사용되는 8080포트가 마음에 안들거나, 다른 포트를 사용해야 될 경우가 빈번하다. 그럴때는 <strong>application.properties</strong>파일에 설정을 추가해주면 된다. 아래와 같이 설정을 추가해보자.</p>
<div class="language-properties highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="py">server.port</span><span class="p">=</span><span class="s">8081</span>
</code></pre></div></div>
<p>그 다음 서버를 재시작한 뒤 http://localhost:8081로 접속하여 제대로 접속이 되는 지 확인해보자.</p>
<p><img src="\assets\built\images\start-spring\start-spring-18.JPG" alt="start-spring-18" /></p>
<h2 id="추가-설정-코드-수정-시-서버-자동-재시작-reload-hot-load">추가 설정: 코드 수정 시 서버 자동 재시작 (reload, hot load)</h2>
<p>서버 코드를 수정하게 되면 java 부분은 당연히 재시작을 해야 반영이 되지만, jsp나 정적인 js, image 등등을 수정했을 때도 서버를 재시작해줘야 하는 번거로움이 있다. 이 번거로움을 해결하기 위해 스프링에선 devtools 라는 모듈을 제공하는데, 서버의 코드가 수정되면 자동으로 재시작 및 리로드를 해주는 모듈이다. <em>(java 수정시엔 자동 재시작, jsp나 정적 파일 수정 시엔 재시작 없이 자동 reload)</em></p>
<p>해당 모듈은 pom.xml에 아래 코드를 추가하면 사용할 수 있다.</p>
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><dependency></span>
<span class="nt"><groupId></span>org.springframework.boot<span class="nt"></groupId></span>
<span class="nt"><artifactId></span>spring-boot-devtools<span class="nt"></artifactId></span>
<span class="nt"><optional></span>true<span class="nt"></optional></span>
<span class="nt"></dependency></span>
</code></pre></div></div>
<p>모듈 적용을 위해 수동으로 서버 재시작 후, 코드를 수정해보자. 자동으로 서버가 재시작되거나 jsp 수정 후 브라우저 새로고침 시에 수정내용이 반영되면 모듈이 반영된 것이다.</p>
</div>
</section>
<a href='/tag/spring/'>SPRING</a>,
<a href='/tag/sts/'>STS</a>,
<a href='/tag/jsp/'>JSP</a>
<!-- Email subscribe form at the bottom of the page -->
<!--
<section class="subscribe-form">
<h3 class="subscribe-form-title">Subscribe to SimpleHan Lab</h3>
<p>Get the latest posts delivered right to your inbox</p>
<span id="searchform" method="post" action="/subscribe/" class="">
<input class="confirm" type="hidden" name="confirm" />
<input class="location" type="hidden" name="location" />
<input class="referrer" type="hidden" name="referrer" />
<div class="form-group">
<input class="subscribe-email" onkeyup="myFunc()"
id="searchtext" type="text" name="searchtext"
placeholder="Search..." />
</div>
<script type="text/javascript">
function myFunc() {
if(event.keyCode == 13) {
var url = encodeURIComponent($("#searchtext").val());
location.href = "/search.html?query=" + url;
}
}
</script>
</span>
</section>
-->
<footer class="post-full-footer">
<!-- Everything inside the #author tags pulls data from the author -->
<!-- #author-->
<section class="author-card">
<img class="author-profile-image" src="/assets/built/images/author-logo.jpg" alt="Simplehan" />
<section class="author-card-content">
<h4 class="author-card-name"><a href="/author/Simplehan">Simplehan</a></h4>
<p>We are amazing developers.</p>
</section>
</section>
<div class="post-full-footer-right">
<a class="author-card-button" href="/author/Simplehan">Read More</a>
</div>
<!-- /author -->
</footer>
<!-- If you use Disqus comments, just uncomment this block.
The only thing you need to change is "test-apkdzgmqhj" - which
should be replaced with your own Disqus site-id. -->
<section class="post-full-comments">
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
var this_page_url = 'https://simplehanlab.github.io/start-spring';
var this_page_identifier = '/start-spring';
var this_page_title = 'Spring 프레임워크를 이용한 프로젝트 생성 (with STS, JSP)';
};
(function() {
var d = document, s = d.createElement('script');
s.src = 'https://simplehanlab.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
</section>
</article>
</div>
</main>
<!-- Links to Previous/Next posts -->
<aside class="read-next outer">
<div class="inner">
<div class="read-next-feed">
<article class="read-next-card"
style="background-image: url(/assets/built/images/blog-cover1.png)"
>
<header class="read-next-card-header">
<small class="read-next-card-header-sitetitle">— SimpleHan Lab —</small>
<h3 class="read-next-card-header-title"><a href="/tag/spring/">Spring</a></h3>
</header>
<div class="read-next-divider"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 14.5s2 3 5 3 5.5-2.463 5.5-5.5S21 6.5 18 6.5c-5 0-7 11-12 11C2.962 17.5.5 15.037.5 12S3 6.5 6 6.5s4.5 3.5 4.5 3.5"/></svg>
</div>
<div class="read-next-card-content">
<ul>
<li><a href="/jasper-2">JasperReports Java Spring project 연동 사용법</a></li>
</ul>
</div>
<footer class="read-next-card-footer">
<a href="/tag/spring/">
See all 1 posts →
</a>
</footer>
</article>
<!-- If there's a next post, display it using the same markup included from - partials/post-card.hbs -->
<article class="post-card post-template">
<a class="post-card-image-link" href="/add-bootstrap">
<div class="post-card-image" style="background-image: url(/assets/built/images/start-spring/spring-logo.png)"></div>
</a>
<div class="post-card-content">
<a class="post-card-content-link" href="/add-bootstrap">
<header class="post-card-header">
<span class="post-card-tags">Spring</span>
<span class="post-card-tags">Sts</span>
<span class="post-card-tags">Jsp</span>
<span class="post-card-tags">Bootstrap</span>
<h2 class="post-card-title">Spring 프로젝트에 Bootstrap 적용하기</h2>
</header>
<section class="post-card-excerpt">
<p>프론트엔드를 개발하다보면 UI 개발도 같이 진행이 되는데, 이를 개발자가 직접 CSS를 작성하면서 개발하게 되면 개발 기간이 많이 늘어날 수 밖에 없다. 이럴 때 미리 개발되어 있는 UI 프레임워크 등을 가져다 쓰면 편리하지 않을까?</p>
</section>
</a>
<footer class="post-card-meta">
<img class="author-profile-image" src="/assets/built/images/author-logo.jpg" alt="Simplehan" />
<span class="post-card-author">
<a href="/author/Simplehan/">Simplehan</a>
</span>
<span class="reading-time">
2 min read
</span>
</footer>
</div>
</article>
<!-- If there's a previous post, display it using the same markup included from - partials/post-card.hbs -->
<article class="post-card post-template">
<a class="post-card-image-link" href="/google-map-react3">
<div class="post-card-image" style="background-image: url(/assets/built/images/react/react-logo.png)"></div>
</a>
<div class="post-card-content">
<a class="post-card-content-link" href="/google-map-react3">
<header class="post-card-header">
<span class="post-card-tags">Javascript</span>
<span class="post-card-tags">React</span>
<span class="post-card-tags">Node</span>
<span class="post-card-tags">Google</span>
<span class="post-card-tags">Map</span>
<h2 class="post-card-title">Google Map API React에서 사용하기 (3)</h2>
</header>
<section class="post-card-excerpt">
<p>1. 추가 응용
</p>
</section>
</a>
<footer class="post-card-meta">
<img class="author-profile-image" src="/assets/built/images/author-logo.jpg" alt="Simplehan" />
<span class="post-card-author">
<a href="/author/Simplehan/">Simplehan</a>
</span>
<span class="reading-time">
1 min read
</span>
</footer>
</div>
</article>
</div>
</div>
</aside>
<!-- Floating header which appears on-scroll, included from includes/floating-header.hbs -->
<div class="floating-header">
<div class="floating-header-logo">
<a href="https://simplehanlab.github.io/">
<span>SimpleHan Lab</span>
</a>
</div>
<span class="floating-header-divider">—</span>
<div class="floating-header-title">Spring 프레임워크를 이용한 프로젝트 생성 (with STS, JSP)</div>
<div class="floating-header-share">
<div class="floating-header-share-label">Share this <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M7.5 15.5V4a1.5 1.5 0 1 1 3 0v4.5h2a1 1 0 0 1 1 1h2a1 1 0 0 1 1 1H18a1.5 1.5 0 0 1 1.5 1.5v3.099c0 .929-.13 1.854-.385 2.748L17.5 23.5h-9c-1.5-2-5.417-8.673-5.417-8.673a1.2 1.2 0 0 1 1.76-1.605L7.5 15.5zm6-6v2m-3-3.5v3.5m6-1v2"/>
</svg>
</div>
<a class="floating-header-share-tw" href="https://twitter.com/share?text=Spring+%ED%94%84%EB%A0%88%EC%9E%84%EC%9B%8C%ED%81%AC%EB%A5%BC+%EC%9D%B4%EC%9A%A9%ED%95%9C+%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8+%EC%83%9D%EC%84%B1+%28with+STS%2C+JSP%29&url=https://simplehanlab.github.io/start-spring"
onclick="window.open(this.href, 'share-twitter', 'width=550,height=235');return false;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M30.063 7.313c-.813 1.125-1.75 2.125-2.875 2.938v.75c0 1.563-.188 3.125-.688 4.625a15.088 15.088 0 0 1-2.063 4.438c-.875 1.438-2 2.688-3.25 3.813a15.015 15.015 0 0 1-4.625 2.563c-1.813.688-3.75 1-5.75 1-3.25 0-6.188-.875-8.875-2.625.438.063.875.125 1.375.125 2.688 0 5.063-.875 7.188-2.5-1.25 0-2.375-.375-3.375-1.125s-1.688-1.688-2.063-2.875c.438.063.813.125 1.125.125.5 0 1-.063 1.5-.25-1.313-.25-2.438-.938-3.313-1.938a5.673 5.673 0 0 1-1.313-3.688v-.063c.813.438 1.688.688 2.625.688a5.228 5.228 0 0 1-1.875-2c-.5-.875-.688-1.813-.688-2.75 0-1.063.25-2.063.75-2.938 1.438 1.75 3.188 3.188 5.25 4.25s4.313 1.688 6.688 1.813a5.579 5.579 0 0 1 1.5-5.438c1.125-1.125 2.5-1.688 4.125-1.688s3.063.625 4.188 1.813a11.48 11.48 0 0 0 3.688-1.375c-.438 1.375-1.313 2.438-2.563 3.188 1.125-.125 2.188-.438 3.313-.875z"/></svg>
</a>
<a class="floating-header-share-fb" href="https://www.facebook.com/sharer/sharer.php?u=https://simplehanlab.github.io/start-spring"
onclick="window.open(this.href, 'share-facebook','width=580,height=296');return false;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M19 6h5V0h-5c-3.86 0-7 3.14-7 7v3H8v6h4v16h6V16h5l1-6h-6V7c0-.542.458-1 1-1z"/></svg>
</a>
</div>
<progress class="progress" value="0">
<div class="progress-container">
<span class="progress-bar"></span>
</div>
</progress>
</div>
<!-- /post -->
<!-- The #contentFor helper here will send everything inside it up to the matching #block helper found in default.hbs -->
<!-- Previous/next page links - displayed on every page -->
<!-- The footer at the very bottom of the screen -->
<footer class="site-footer outer">
<div class="site-footer-content inner">
<section class="copyright"><a href="https://simplehanlab.github.io/">SimpleHan Lab</a> © 2021</section>
<section class="poweredby">Proudly published with <a href="https://jekyllrb.com/">Jekyll</a> &
<a href="https://pages.github.com/" target="_blank" rel="noopener">GitHub Pages</a> using
<a href="https://github.com/jekyllt/jasper2" target="_blank" rel="noopener">Jasper2</a></section>
<nav class="site-footer-nav">
<a href="/">Latest Posts</a>
<a href="https://ghost.org" target="_blank" rel="noopener">Ghost</a>
</nav>
</div>
</footer>
</div>
<!-- The big email subscribe modal content -->
<div id="subscribe" class="subscribe-overlay">
<a class="subscribe-overlay-close" href="#"></a>
<div class="subscribe-overlay-content">
<h1 class="subscribe-overlay-title">Search SimpleHan Lab</h1>
<p class="subscribe-overlay-description">
lunr.js를 이용한 posts 검색 </p>
<span id="searchform" method="post" action="/subscribe/" class="">
<input class="confirm" type="hidden" name="confirm" />
<input class="location" type="hidden" name="location" />
<input class="referrer" type="hidden" name="referrer" />
<div class="form-group">
<input class="subscribe-email" onkeyup="myFunc()"
id="searchtext" type="text" name="searchtext"
placeholder="Search..." />
</div>
<script type="text/javascript">
function myFunc() {
if(event.keyCode == 13) {
var url = encodeURIComponent($("#searchtext").val());
location.href = "/search.html?query=" + url;
}
}
</script>
</span>
</div>
</div>
<!-- highlight.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.10.0/components/prism-abap.min.js"></script>
<script>$(document).ready(function() {
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
});</script>
<!-- jQuery + Fitvids, which makes all video embeds responsive -->
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous">
</script>
<script type="text/javascript" src="/assets/js/jquery.fitvids.js"></script>
<script type="text/javascript" src="https://demo.ghost.io/assets/js/jquery.fitvids.js?v=724281a32e"></script>
<!-- Paginator increased to "infinit" in _config.yml -->
<!-- if paginator.posts -->
<!-- <script>
var maxPages = parseInt('');
</script>
<script src="/assets/js/infinitescroll.js"></script> -->
<!-- /endif -->
<!-- Add Google Analytics -->