일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- MariaDB
- 기출문제
- NoSQL
- swipe 배너
- vue.js
- github
- jdbc
- checkbox
- 마스킹
- bulkinsert
- JAXBContext
- JSON
- 정보처리산업기사
- Ajax
- mybatis
- 부스트코스
- jsp
- insertAll
- 오라클
- query
- spring
- vscode tutorial
- 구멍가게코딩단
- vue Carousel
- mysql
- egov
- Tomcat
- java
- INSERT
- JQuery
- Today
- Total
개발새발
[2019.12.09] 본문
1) spring boot 에서 jsp 화면 띄우기
spring boot는 application.properties에서 설정을 다 해준다고 했다.
-
spring boot에서 jsp를 사용하려면 dependency를 추가해줘야한다.
-
application.properties에 jsp파일을 넣어둘 경로를 지정해준다.
- jsp파일을 만들고
-
Controller 만들어준 다음
-
[프로젝트 우클릭] - [run as] - [spring boot app]으로 돌린후 url에 localhost:8080/hello를 치면
요로코롬 에러가 난다.
에러 : Error resolving template [hello], template might not exist or might not be accessible by any of the configured Template Resolvers 어쩌고 저쩌고
-
application.properties에 spring.thymeleaf.enabled=false를 추가해준다.
2) spring boot에 부트스트랩 적용
-
요기서 부트스트랩을 다운받은 뒤 src/main/webapp/에 resources 폴더를 만들어서 다운받은 css, fonts, js 폴더를 추가해준다.
-
부트스트랩을 사용하려면 pom.xml에 dependency를 추가해줘야한다.
- 그리고 application.properties에서 경로 설정해준 곳에서 jsp파일을 만들어준다. (login.jsp)
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
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>테스트테스트 Login</title>
</head>
<body class="my-login-page">
<section class="h-100">
<div class="container h-100">
<div class="row justify-content-md-center h-100">
<div class="card-wrapper">
<div class="brand">
</div>
<div class="card fat">
<div class="card-body">
<h4 class="card-title text-center text-dark">
Welcome to BASICIT
<span class="badge badge-secondary">
v1.0
</span>
</h4>
<form method="POST">
<div class="form-group">
<label for="id" class="text-secondary">Account</label>
<input id="account" class="form-control" name="account" value="" required autofocus>
</div>
<div class="form-group">
<label for="id" class="text-secondary">Password</label>
<input id="password" type="password" class="form-control" name="password" required>
</div>
<div class="form-group no-margin">
<button type="submit" class="btn btn-info btn-block">
Login
</button>
</div>
</form>
</div>
</div>
<div class="footer">
</div>
</div>
</div>
</div>
</section>
</body>
</html>
|
원래 부트스트랩 폴더 경로 ../resource/css/bootstrap.min~ 뭐 이렇게 잡아줬던거같은데
pom.xml에 dependency 추가해줘서
<link rel="stylesheet" href="/webjars/bootstrap/4.1.0/css/bootstrap.min.css">
이렇게 잡아주는거 같다.
-
login.jsp를 controller에서 mapping 해주고
- [프로젝트 우클릭] - [run as] - [spring boot app]으로 돌린후 localhost:8080/를 치면
- 부트스트랩으로 만들어진 jsp파일이 뜬다.
[스프링부트 부트스트랩 적용 참고링크]
[스프링부트 db연동 참고링크]
*pom.xml에 dependency 추가할때 version 경고 뜨면 </version> 옆에 <!--$NO-MVN-MAN-VER$--> 요거 추가해주면 경고 무시
[db연동하면서 추가한 dependency들]
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
|
<!-- JDBC -->
<dependency>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.2.1.RELEASE</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<!-- MyBatis -->
<dependency>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.2</version>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<!-- BootStrap -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.3.1</version>
</dependency>
<!-- jsp -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
|
[오늘한일]
스프링부트 jsp파일 띄우기
스프링부트 부트스트랩 적용
db정보로 workbench db접속
**스프링부트랑 mysql db연동**
'[Daliy]' 카테고리의 다른 글
[2019.12.13] (0) | 2019.12.13 |
---|---|
[2019.12.12] (0) | 2019.12.12 |
[2019.12.11] (0) | 2019.12.11 |
[2019.12.05] (0) | 2019.12.05 |
[2019.12.04] (0) | 2019.12.04 |