Adding links to every record with Spring REST + MongoDB -


i'm trying add links every record in databse, trying implement hateoas concept. however, have been experiencing trouble this. tried following guide https://spring.io/guides/gs/rest-hateoas/. no success. how , should write code adding links? because doesn't seem work when try write in controller method because withselfrel() undefined.

basically i'm trying add link every account made in database.

    //create account  @requestmapping(value="/accounts", method = requestmethod.post)  public responseentity<?> accountinsert(@requestbody account account) {     account = new account(account.getfirstname(), account.getlastname(), account.getemail(), account.getpassword(), account.getbirthdate(), account.getactivities(), account.getfriends());     accountrepository.save(account);     //account.add(linkto(methodon(accountcontroller.class, accountinsert(account)).withselfrel()));   /// here try     httpheaders httpheaders = new httpheaders();     httpheaders.setlocation(servleturicomponentsbuilder.fromcurrentrequest().build().touri());     return new responseentity<>(null, httpheaders, httpstatus.created); } 

thank in advance!

you can not use method inside same one
try :-

link self=linkto(accountcontroller.class).slash(account.getid()).withselfrel(); 

or can refer given link


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -