2016-02-25 78 views
2

例如,我想将当前请求中的cookie的值绑定到下面的pojo。如何将cookie值绑定到Spring MVC中的pojo字段?

@RequestMapping(path="/", method= GET, produces = MediaType.APPLICATION_JSON_VALUE) 
public ResponseEntity<?> handleTheRequest(Foo foo){ 
    return blah; 
} 

public class Foo{ 
    private string cookieValue; 
    //Other fun fields 

    public void setCookieValue(String value){ 
     this.cookieValue = value; 
    } 

    public string getCookieValue(){ 
     return cookieValue; 
    } 
} 

回答

0

你可以试试吗?

@RequestMapping(path="/", method= GET, produces = MediaType.APPLICATION_JSON_VALUE) 
public ResponseEntity<?> handleTheRequest(@RequestBody Foo foo){ 
    return blah; 
} 
相关问题