java - Cookie troubles with Spring MVC -


i trying cookie value using @cookie. 400 error if cookie value null. what's wrong? controller:

    public string listcontacts(map<string, object> map,             httpservletresponse response, @cookievalue("flag") string flag) {            response.addcookie(new cookie("flag", "in use")); ... 

try setting required = false in @cookievalue annotation:

public string listcontacts(map<string, object> map,       httpservletresponse response, @cookievalue(value = "flag", required = false) string flag) { 

by default spring expects cookie header present , throws exception otherwise:

default true, leading exception being thrown in case header missing in request. switch false if prefer null in case of missing header.

alternatively, provide defaultvalue, implicitly sets flag false.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -