@RequestParam Request Header에 Parameter를 넣어 전달
@RequestBody Request Body에 Data를 넣어 전달
@RequestMapping("/create")
public Map<String, Object> create(@RequestBody Map<String ,Object> data, HttpServletRequest request) throws PageException
{
createState(getLoginUserId(request),"생성");
Map<String, Object> result;
PostVo postVo = new PostVo();
postVo.setTitle(data.get("title").toString());
postVo.setContent(data.get("content").toString());
postVo.setUserId(getLoginUserId(request));
result = postService.createPost(postVo);
return result;
}
const title = $("#title").val();
const content = $("#content").val();
const data = { title: title, content: content };
fetch("/post/create", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})