The jquery example:
(function($){
var profile = {
"name" : "John, Walsh",
"job" : "FBI",
};
$.ajax({
type : "POST",
url : "/profile",
data : JSON.stringify(profile),
dataType : "json",
contentType : "application/json",
success : function(response) {
$("#response").empty().append(response);
},
});
})(jQuery);
The java bean example:
package extendit;
public class Profile {
private String name;
private String job;
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setJob(Stirng job) {
this.job = job;
}
public String getJob() {
return this.job;
}
}
The controller example:
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ProfileRestController {
@RequestMapping(value="/profile", method= RequestMethod.GET)
public Profile profile(@RequestBody Profile profile) {
return profile
}
}