1

Is it possible to put @CookieValue in a parameter object? I can't seem to get this to work whats is missing?

@RequestMapping(value = "/Users", method = RequestMethod.GET)
@ResponseBody
public Response getAllActiveUsers(CookieParameters parameterObject) {

  return getUserImpl.getAllActiveUsers(parameterObject.userToken,
                 parameterObject.loggedInUserId);
}

Here is the parameter object class.

public class CookieParameters {
public String userToken;
public String loggedInUserId;

public CookieParameter(
    @CookieValue(value = "Token", defaultValue = "") final String userToken,
    @CookieValue(value = "LoggedInUserId", defaultValue = "") final String  loggedInUserId) {
    this.userToken = userToken;
    this.loggedInUserId = loggedInUserId;
}
Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121

1 Answers1

1

I do not think this is possible. From my understanding, the @CookieValue can only be put on the parameters of a handler method. I think you would have to grab the @CookieValue and put them in your parameter object manually.

Osama Aftab
  • 1,161
  • 9
  • 15
CodeChimp
  • 8,016
  • 5
  • 41
  • 79