Spring MVC-从零开始-@RequestMapping 注解headers 属性

package com.jt;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value="/FirstControl")
public class HelloControl {
    @RequestMapping(value="/hasHead",headers={"context-type=text/plain","context-type=text/html"})
    @ResponseBody
    public String headType1(){
        return "headType";
    }
    
    @RequestMapping(value="/hasnotHead")
    @ResponseBody
    public String headType2(){
        return "headType";
    }
    
}

效果1


效果2

原文地址:https://www.cnblogs.com/jiangtao1218/p/8586305.html