请求头header中很重要的两个参数:
Accept:text/html
只在响应中存在,表示当前请求希望服务器将来返回的数据类型是text/html
Content-Type:application/json
既可以出现在请求中,也可以出现在响应中,例如
响应中代表服务器响应的是什么数据类型
响应中response.setContentType("text/html;charset=utf-8");
请求中代表客户端所携带的参数是什么类型
consumes 指定处理请求的提交内容类型(消费)
produces 指定返回的内容类型(生产)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/d62e99793a48863d1895a5f0ad9f1e32.png)
@RequestMapping("/request_header")
@Controller
public class RequestHeaderController {
@RequestMapping(value="/test6",consumes= {"application/json"})
public String test6(){
System.out.println("RequestHeaderController test6()...");
return "test";
}
@RequestMapping(value="/test7",produces= {"application/json"})
public String test7(){
System.out.println("RequestHeaderController test7()...");
return "test";
}
@RequestMapping(value="/test8",produces= {"application/json"},consumes= {"application/json"})
public String test8(){
System.out.println("RequestHeaderController test8()...");
return "test";
}
}
*/* 代表所有类型