@requestMapping中produces的作用

produces是注解@requestMapping注解里面的属性项,它的作用是指定返回值类型。

使用方法如下:

返回json数据,字符编码为utf-8.:

@RequestMapping(value = "exportExcel", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
	@ApiOperation(value = "将公文信息到处为excel", httpMethod = "GET", notes = "将公文信息导出为excel")
	public void exportExcel(HttpServletRequest request, HttpServletResponse response, String statisticalType) {
		try {
			// 声明一个工作薄
			HSSFWorkbook wb = new HSSFWorkbook();
........................................................
........................................................
}

 

你可能感兴趣的:(spring,java注解)