study

(230605) Java 및 Spring 이론, web연결

hjkeeeem 2024. 7. 25. 20:30

컴퓨터는 어떻게 Java를 이해하는 걸까?

프로그래밍 언어란?

Compute + er = 계산하는 사람 , 문맥과 상식이 존재하지 않음

 

처음 Spring Project 생성 시 제공되는 Application 파일

package com.example.LikelionSpring;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

//http://localhost:8080/home -> 주소를 주소창에 입력했을 때
// 우리가 만든 HTML이 보이게 해보자.

@SpringBootApplication
public class LikelionSpringApplication {

	public static void main(String[] args) {
		SpringApplication.run(LikelionSpringApplication.class, args);
	}

}

 

 

@Controller를 이용하여 import 생성 및 templates에 생성한 html 파일 띄우기

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LikelionController {
    @RequestMapping("/home")
    public String home(){
        return "home.html";
    }
}

 

 

resource > templates > home.html 작성

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
HELLO Spring boot
hello works
hi jeeho

</body>
</html>

모든 파일 작성 후 Application 파일에서 run 실행 > localhost:8080/home 접속

 

IOC 컨테이너에 대해서 

 

 

 

'study' 카테고리의 다른 글

AWS & Docker - container 편집, glances  (0) 2024.07.25
(230607) Spring MVC 이론 및 실습  (0) 2024.07.25
(230602) Springboot DB연결  (0) 2024.07.25
(230526) 인터페이스, 제네릭  (0) 2024.07.25
(230524) DB  (0) 2024.07.25