일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 백준
- c#
- 인프런
- 완전탐색
- Java
- appendleft
- 누적합
- 파이썬
- DP
- 프로그래머스
- 합 구하기
- LCM
- deque
- mvc
- unity
- 우선순위큐
- BFS
- Python
- C#강의
- JPA
- spring
- popleft
- 소수판별
- python3
- 연관관계
- 브루투포스
- 소수찾기
- 1일1솔
- pypy3
- 그리디 알고리즘
Archives
- Today
- Total
jae_coding
Spring 매개변수 출력하기 본문
반응형
Project 생성
-. Gradle 추가시키기
-. hello.html추가시키기
-. Controller를 Getmapping 이용하기
@GetMapping("/hello")
-. Port번호 변경시키기 (application.properties)
저의 경우에는 8081 포트 이용
server.port=8081
-. url이동
localhost:8081/hello?name=name
Build.gradle
plugins {
id 'org.springframework.boot' version '2.7.3'
id 'io.spring.dependency-management' version '1.0.13.RELEASE'
id 'java'
}
group = 'spring'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
//lombok 관련
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// 테스트 의존성 추가
testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'}
}
tasks.named('test') {
useJUnitPlatform()
}
hello.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<!-- 한글 utf-8 설정 -->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>$Title$</title>
</head>
<body>
<h1>Hello Spring!!!</h1>
<div th:text="${name}"></div>
</body>
</html>
Hello_Controller
package spring.login_project.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class Hello_controller {
@GetMapping("/hello")
public String hello(String name, Model model) {
model.addAttribute("name", name);
//html명을 반환하기
return "hello";
}
}
-. 실행화면
반응형
'Spring, java' 카테고리의 다른 글
[스프링 핵심 원리]객체 지향 설계 & 스프링 (0) | 2022.08.24 |
---|---|
(Spring, Java) MVC, 템플릿 엔진, port변경 (0) | 2022.08.12 |
(Spring, Java) Build and Run (0) | 2022.08.11 |
(Spring, Java) Welcome Page (static, dynamic) (0) | 2022.08.11 |
(Spring, java) 시작하기, 설정하기 (0) | 2022.08.11 |
Comments