# 示例

客户端发送文档

@Slf4j
@RequestMapping("/test")
@Controller
public class TestController {


	@RequestMapping("/responseEntity")
	public ResponseEntity<byte[]> responseEntity(HttpSession session) throws IOException {
		//读文件
		byte[] body = null;
		ServletContext servletContext = session.getServletContext();
		InputStream in = servletContext.getResourceAsStream("/banner.txt") ;//servletContext.getRealPath("/banner.txt") ; 
		log.info(in.getClass().toString());
		body = new byte[in.available()] ;
		in.read(body) ; 
		//返回状态
		HttpStatus status = HttpStatus.OK ;
		//响应求头
		HttpHeaders headers = new HttpHeaders() ;
		headers.add("Content-Disposition", "attachment;filename=FileName.txt");
		ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(body, headers, status) ; 
		return response ; 
	}
}



原理

# 在哪里


# 干什么




# 怎么用(实现 )





# 备忘