java - REST resource call from JavaScript -
i have web app has js code follows (uses backbone.js model);
var studentdemographic = basemodel.extend({ idattribute: 'studentid', url: 'api/list/student/demographic', urlroot: 'api/list/student/demographic', defaults: { gender: null, age: null, dob: null, } });
now, there call java (rest resource) , unable understand how called exactly. java code (rest resource) looks like;
@path("/list") public class studentlistresource extends baseresource { @get @path("/student/demographic") @consumes({mediatype.application_json}) @produces({mediatype.application_json}) @override public studentdemographic getstudentdemographic(@queryparam("studentid") string studentid) { } }
my question how mapping there between js call api/list/student/demographic , corresponding java method. handled java library internally or need configuration in project. please me understand. front-end dev, not clear backend integration.
also if me understand lines in java code @get, @put, @override, etc (like mean), great?
looks rest application.
the mapping done web application container (java ee/spring/...), exact configuration might vary. basic mapping definition done @path annotations(here class studentlistresource handles request going /list , concrete method getstudentdemographic handles "relative url" /student/demographic, /list/student/demographic. url relative web application, assume called "api" (or @ least mapped /api/**)
@get annotation says handles http request, @put, @post etc
@consumes , @produces specifies input , output expected json, mapped java objects, input method taken query (@queryparam)
@override java language annotation indicating method overridden super class, not have special meaning mapping.
Comments
Post a Comment