一、介绍
可以自定义返回给浏览器的响应报文
二、项目测试
(1)编写Controller类
@Controller
public class MyController {
@RequestMapping(value = {"/hello"})
public ResponseEntity<String> hello(){
//响应状态码
HttpStatus ok = HttpStatus.OK;
//响应头
MultiValueMap<String, String> headers = new HttpHeaders();
headers.add("Content-Type", "text/html;charset=UTF-8");
ResponseEntity<String> responseEntity = new ResponseEntity("hello", headers, ok);
return responseEntity;
}
}
(2)运行