Post 방식
jsp
function ajaxPost(){
	var params = {
		 name : "홍길동"
		,userNo : 10 
	}
	
	$.ajax({
        url: "/ajaxPost",
        type: "POST",
        data: params,
        success: function(data){
            console.log(data.resultCd);
            console.log(data.resultMsg);
        },
        error: function(){
            alert("데이터 통신중 에러발생");
        }
    });
}
200
post 통신이 성공하였습니다.
Controller
@Controller
public class MainController {

	@ResponseBody
	@PostMapping(value = {"/ajaxPost"})
	public Map<String, Object> ajaxPost(@RequestParam Map<String, Object> params, HttpServletRequest req, HttpServletResponse res) {
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("resultCd", "200");
		result.put("resultMsg", "post 통신이 성공하였습니다.");
		System.out.println(params);
		return result;
	}
    
}
{userNo=10, name=홍길동}

 

Get 방식
jsp
function ajaxGet(){
	
	var params = {
		name : "김철수"
		,userNo : 20
	}
	
	var data = $.param(params);
	location.href = "/ajaxGet?"+data;
	
}	
Cotroller
@GetMapping(value = "/ajaxGet")
	public void ajaxGet(@RequestParam Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) throws Exception, Exception {
		System.out.println(params);
	}
{userNo=20, name=김철수}
복사했습니다!