ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๋ฐ˜์‘ํ˜•
View ํ™”๋ฉด ์ฒ˜๋ฆฌ

๋จผ์ € ๊ฒŒ์‹œํŒ์˜ ํ™”๋ฉด๋“ค์„ ๋ชจ์•„ ๋†“์„ ํด๋”๋ฅผ ๋งŒ๋“ค์–ด ๋†“๋Š”๋‹ค.

(jsp๋Š” ๋ถ€ํŠธ์ŠคํŠธ๋žฉ์„ ์ด์šฉํ•ด์„œ ๋งŒ๋“ค์—ˆ์Œ ๋”ฐ๋กœ ์ฝ”๋“œ๋ฅผ ์ ์–ด๋†“์ง€ ์•Š๊ฒ ์Œ)

 

 

BoardController.java

์ปจํŠธ๋กค๋Ÿฌ๋Š” ๋ชจ๋“  ์š”์ฒญ์„ ๋ฐ›๋Š” ์—ญํ• ์„ ํ•˜๋Š” ๊ณณ์ด๋‹ค.

BoardController๋Š” ๊ฒŒ์‹œํŒ์˜ ๋ชจ๋“  ์š”์ฒญ์„ ๋ฐ›์•„์ค„ ํด๋ž˜์Šค์ด๋‹ค.

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
package com.spring.myapp.board.controller;
 
import java.util.List;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
 
import com.spring.myapp.board.model.BoardVO;
import com.spring.myapp.board.service.IBoardService;
 
//๊ฒŒ์‹œํŒ ์ž์› ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•ด ์ค„ ์ปจํŠธ๋กค๋Ÿฌ์ด๋‹ค. -> ๊ทธ๋Ÿฌ๊ธฐ ์œ„ํ•ด ๋นˆ๋“ฑ๋ก์„ ํ•ด์ฃผ์–ด์•ผํ•œ๋‹ค.
@Controller //์ปจํŠธ๋กค๋Ÿฌ ๋นˆ๋“ฑ๋กํ•ด์ฃผ๋Š” ์–ด๋…ธํ…Œ์ด์…˜
@RequestMapping("/board"//"/board"์š”์ฒญ์ด ๋“ค์–ด์˜ฌ ๋•Œ ๋‹ค ์—ฌ๊ธฐ์„œ ์ฒ˜๋ฆฌํ•˜๊ฒ ๋‹ค ํ•˜๋Š” ๊ณตํ†ต URL์ž‘์„ฑ!!
public class BoardController {
    
    //๋กœ๊ฑฐ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๋กœ๊ฑฐ๊ฐ์ฒด ์„ ์–ธ
    private static final Logger logger = LoggerFactory.getLogger(BoardController.class);
    
    //์ปจํŠธ๋กค๋Ÿฌ์™€ ์„œ๋น„์Šค๊ฐ€ ์˜์กด๊ด€๊ณ„๊ฐ€ ์„ค์ •๋˜์–ด์žˆ์œผ๋‹ˆ ์˜์กด์„ฑ์ฃผ์ž…ํ•ด์ค€๋‹ค.
    @Autowired
    private IBoardService service;
 
 
 
}
 

 

 

 

IBoardService.java

์ปจํŠธ๋กค๋Ÿฌ์™€ ๋ ˆํŒŒ์ง€ํ† ๋ฆฌ ์‚ฌ์ด์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ •์ œํ•˜๋Š” ๊ณณ์ด ์„œ๋น„์Šค ๊ณ„์ธต์ด๋‹ค.

์ธํ„ฐํŽ˜์ด์Šค๋กœ ๋จผ์ € ๋งŒ๋“ค์–ด์ค€๋‹ค.

1
2
3
4
5
6
7
8
9
10
11
package com.spring.myapp.board.service;
 
import java.util.List;
 
import com.spring.myapp.board.model.BoardVO;
 
public interface IBoardService {
//์„œ๋น„์Šค์—์„œ ์‚ฌ์šฉํ•  ๋ฉ”์„œ๋“œ๋“ค์„ ๋‚˜์—ด์„ ํ•ด๋ณผ๊ฑด๋ฐ DAO์™€ ๊ฐ™๊ฒŒ ํ•œ๋‹ค.
//๋ฐ์ดํ„ฐ๋ฅผ ์ •์ œํ•˜๋Š” ๊ณณ์ด ์„œ๋น„์Šค ๊ณ„์ธต
 
}
 
๋ฐ˜์‘ํ˜•
๋Œ“๊ธ€