2025-04-28
axios.get(projectPath + "/rest/memo/add?id=" + form.id.value + "&text=" + form.text.value)
.then(resp => console.log(resp))
.catch(err => console.log(err));
const headers = { 'Content-Type': 'application/json' };
const param = { "id": form.id.value, "text": form.text.value };
axios.post(projectPath + "/rest/memo/post", param, headers)
.then(resp => console.log(resp))
.catch(err => console.log(err));
axios.put(projectPath + "/rest/memo/put2/" + form.id.value + "/" + form.text.value)
.then(resp => console.log(resp))
.catch(err => console.log(err));
axios.delete(projectPath + "/memo/remove/" + form.id.value)
.then(resp => console.log(resp))
.catch(err => console.log(err));
๊ตฌ๋ถ | ๋๊ธฐ(Sync) | ๋น๋๊ธฐ(Async) |
---|---|---|
์ฒ๋ฆฌ ๋ฐฉ์ | ์์ฒญ ํ ์๋ต๊น์ง ๋๊ธฐ | ์์ฒญ ํ ๋ฐ๋ก ๋ค์ ์์ |
์ฌ์ฉ์ ๊ฒฝํ | ํ์ด์ง ์๋ก๊ณ ์นจ ๋ฐ์ | ํ์ด์ง ์ ์ง |
๋ํ ์์ | HTML Form, ๊ธฐ๋ณธ GET | Ajax, Fetch, Axios |
์ฅ์ | ๊ตฌํ์ด ๋จ์ | ๋น ๋ฅธ ์๋ต, UX ํฅ์ |
๋จ์ | ๋๊ธฐ ์๊ฐ ๋ฐ์ | ๋ณต์กํ ๋ก์ง ๊ฐ๋ฅ์ฑ |
@RestController
@Slf4j
@RequestMapping("/rest/memo")
public class MemoRestController {
@Autowired
private MemoServiceImpl memoService;
@GetMapping("/getAll")
public List<MemoDto> getAll() { ... }
@GetMapping("/get/{id}")
public ResponseEntity<MemoDto> get(@PathVariable int id) { ... }
@PostMapping("/post")
public void add(@RequestBody MemoDto dto) throws SQLException { ... }
@PutMapping("/put/{id}/{text}")
public void put(MemoDto dto) { ... }
@PutMapping("/put2")
public void put2(@RequestBody MemoDto dto) { ... }
@PatchMapping("/patch/{id}/{text}")
public void patch(MemoDto dto) { ... }
@DeleteMapping("/remove/{id}")
public void remove(@PathVariable int id) { ... }
}