종우의 컴퓨터 공간

제이쿼리(jQuery) js 신텍스 본문

스프링 부트 (SpringBoot)

제이쿼리(jQuery) js 신텍스

종우공간 2021. 7. 13. 09:07

$('#<id>').on()

- Attach an event handler function for one or more events to the selected elements.

 

$('#<id>').val()

- Get the current value of the first element in the set of matched elements.

 

$.ajax()

- Perform an asynchronous HTTP (Ajax) request.

- Controller의 API를 부를 때 사용한다.

 

data: JSON.stringify(<data>)

- Convert a JavaScript object into a string. The result will be a string following the JSON notation.

- Controller에서 이 data를 받을 때의 형식은 JSON 노테이션을 따른 스트링 형태이다. Spring automatically deserializes the JSON into a Java type, assuming an appropriate one is specified. (스프링 @Requestbody의 특성) 따라서 이름끼리의 매핑만 잘 된다면, 원하는 값이 들어간 객체가 자동으로 만들어진다.

- 결론은 JSON.stringify(json문자열)로 넘어온 파라미터는 서버에서 @RequestBody를 이용하면 받을 수 있다.

 

window.location.href = '/'

- 메인페이지로 이동한다. (ex. 글 등록이 성공하면 처음 페이지로 돌아간다.)

'스프링 부트 (SpringBoot)' 카테고리의 다른 글

Querydsl 개념과 신텍스  (0) 2021.07.14
머스테치(Mustache) 신텍스  (0) 2021.07.13
부트 스트랩(Boot Strap)과 제이쿼리(jQuery) 개념  (0) 2021.07.13
템플릿 엔진(Template Engine)  (0) 2021.07.13
REST API  (0) 2021.07.11