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