Java Spring MVC中的Gzip专用控制器
有没有办法在spring中为一个方法或控制器添加GzipJava Spring MVC中的Gzip专用控制器,java,spring,rest,spring-mvc,gzip,Java,Spring,Rest,Spring Mvc,Gzip,有没有办法在spring中为一个方法或控制器添加Gzip @RequestMapping(value = "/system", method = {RequestMethod.GET}) @Gzip //<- Something similar this, public ApiResponse status() throws Exception{ } @RequestMapping(value=“/system”,method={RequestMethod.GET}) @Gzip/在将
@RequestMapping(value = "/system", method = {RequestMethod.GET})
@Gzip //<- Something similar this,
public ApiResponse status() throws Exception{
}
@RequestMapping(value=“/system”,method={RequestMethod.GET})
@Gzip/在将内容写入客户端之前,可以将java.io.OutputStream
或javax.servlet.http.HttpServletResponse
(对于特定的Gzip http头)作为参数包装到控制器方法中
@RequestMapping(value = "/system", method = {RequestMethod.GET})
public void status(HttpServletResponse response) throws Exception {
try(GZIPOutputStream out = new GZIPOutputStream(response.getOutputStream())) {
// write to out the content
}
}
但所有这些例子都是在过滤器级别向gzip解释的,我希望在控制器或控制器方法级别做出决定