My Web-service Method is and i want to access this method by mobile client :-
@RequestMapping(value = "/login", method = RequestMethod.POST,
headers="Accept=application/json")
public @ResponseBody List<LogInStatus> getLogIn(@RequestBody LogIn person ,
HttpServletRequest request) {
// Call service here
List<LogInStatus> lList = logInService.getUser(person);
//service method and then in DAO database method is there
return lList;
}
sol:
You don't need to create session manually - this is done by servlet container.You can obtain session from HttpServletRequest
HttpSession session = request.getSession();
or just add it as a method parameter, and Spring MVC will inject it for you:public @ResponseBody List<LogInStatus> getLogIn(@RequestBody LogIn person , HttpServletRequest request, HttpSession httpSession)
You then can save user details in session via setAttribute()
/getAttribute()
.
No comments:
Post a Comment