SpringMVC(十) RequestMapping RequestHeader注解
在控制器方法中,通过类似 RequestHeader(value="Accept-Lanaguage") String lan 可以获取请求头信息。
控制器方法:
package com.tiekui.springmvc.handlers; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class RequestHeaderTest { @RequestMapping("testRequestHeader") public String testRequestHeader(@RequestHeader(value="Accept-Language") String language) { System.out.println(language); return "success"; } }
视图内容
<a href="testRequestHeader">TestRequestHeader-video9</a>
https://github.com/godmaybelieve