SpringMVC(十) RequestMapping RequestHeader注解

在控制器方法中,通过类似 RequestHeader(value="Accept-Lanaguage") String lan 可以获取请求头信息。

 

控制器方法:

SpringMVC(十) RequestMapping RequestHeader注解
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";
    }
    
    
}
SpringMVC(十) RequestMapping RequestHeader注解

 

视图内容

<a href="testRequestHeader">TestRequestHeader-video9</a>

SpringMVC(十) RequestMapping RequestHeader注解

上一篇:Java提高篇(三四)-----fail-fast机制


下一篇:N-Queens II leetcode java