web services - How to handle POST restful webservice in Spring MVC which consume and produce data and image both -
i developing webservice contain information image , example , develop webservice contain user information photo. want done post request. how can achieve this?
i want store image path in database.
what changes should make in controller retrive image mobile , store in database? taking userinfotemp object request body.
to developing webservice using spring mvc 4.0.3.release.
here code please review it:
@entity public class userinfotemp { @id @generatedvalue @column(name="userid") private long id; @column(name="firstname") private string firstname; @column(name="lastname") private string lastname; @column(name="email") @jsonproperty(value="email") private string email; @column(name="phone") private string phone; @column(name="profilepiclink") private string profilepiclink; @column(name="profilepicthumbnaillink") private string profilepicthumbnaillink; //getter setter } controller:-
// registering user @requestmapping(value = "/register", method = requestmethod.post) public responseentity<object> register(@requestbody userinfotemp userinfotemp) { try { userinfoservice.save(userinfotemp); return new responseentity<object>(userinfotemp, httpstatus.created); } catch(exception e) { message message = new message(); message.setstatus(false); message.setmessage("user information can not null"); return new responseentity<object>(message, httpstatus.created); } }
Comments
Post a Comment