Spring HttpServletResponse集字符集在Quarkus/undertow中不起作用

Spring HttpServletResponse集字符集在Quarkus/undertow中不起作用,spring,servlets,quarkus,Spring,Servlets,Quarkus,我正在尝试使用原始Http servlet api处理基于Quarkus的Spring应用程序中的异常 源代码: @ExceptionHandler(Exception2.class) public void handleException2(Exception2e,HttpServletResponse响应)引发IOException{ PrintWriter out=response.getWriter(); setContentType(“应用程序/json”); 响应。setCharac

我正在尝试使用原始Http servlet api处理基于Quarkus的Spring应用程序中的异常

源代码:

@ExceptionHandler(Exception2.class)
public void handleException2(Exception2e,HttpServletResponse响应)引发IOException{
PrintWriter out=response.getWriter();
setContentType(“应用程序/json”);
响应。setCharacterEncoding(“UTF-8”);
response.setStatus(HttpServletResponse.SC_BAD_请求);
out.write(“{\”message\:\”+e.getMessage()+“\”}”);
out.flush();
}
当我运行应用程序时,访问url以测试此异常

@GetMapping(“e2”)
公共责任例外2(){
抛出新异常2(“错误2”);
}
捕获异常时,它总是将字符集设置为ISO-8859-1

curl-vhttp://localhost:8080/e2
*正在尝试::1。。。
*TCP_节点集
*已连接到本地主机(::1)端口8080(#0)
>GET/e2 HTTP/1.1
>主机:本地主机:8080
>用户代理:curl/7.55.1
>接受:*/*
>
我不确定这是一个拖航或夸克斯的问题

完整的代码是

更新:通过更改代码顺序修复了此问题,有关详细说明,请参阅

response.setContentType(“应用程序/json”);
响应。setCharacterEncoding(“UTF-8”);
response.setStatus(HttpServletResponse.SC_BAD_请求);
PrintWriter out=response.getWriter();
out.write(“{\”message\:\”+e.getMessage()+“\”}”);
out.flush();

有趣的问题!我稍后会看一看,看看这是否只是Spring兼容性的问题,还是RESTEasy+Undertow也会出现这种情况。在没有任何Spring功能的情况下使用RESTEasy+Undertow时,它确实似乎被忽略了。您能打开一个问题吗?请@Hantsy?创建问题吗