springmvc 注解 RequestParam/RequestHeader/CookieValue
RequestParam注解:
示例:
@RequestMapping("/testRequestParam") public String testRequestParam(@RequestParam(name="username") String un,@RequestParam(name="age",required=false,defaultValue="0") int age) { System.out.println("testRequestParam: username="+un+" age="+age); return SUCCESS; }
RequestHeader注解:
示例:
@RequestMapping("/testRequestHeader") public String testRequestHeader(@RequestHeader(name="Accept-Language") String al) { System.out.println("testRequestHeader: al=" + al); return SUCCESS; }
CookieValue注解:
示例:
@RequestMapping("/testCookieValue") public String testCookieValue(@CookieValue(name="JSESSIONID") String sid) { System.out.println("testCookieValue:sid="+sid); return SUCCESS; }
邮箱:wangh_2@sina.com