forked from loafle/openapi-generator-original
[Spring] Fix character conversion error (#1195)
* Fix character conversion error ref https://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/ServletResponse.html > To send character data, use the PrintWriter object returned by getWriter() * Update samples * Update spring-stubs
This commit is contained in:
parent
1a61456f71
commit
68a8f2976c
@ -16,8 +16,10 @@ public class ApiUtil {
|
|||||||
{{^reactive}}
|
{{^reactive}}
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
try {
|
try {
|
||||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import java.io.IOException;
|
|||||||
public class ApiUtil {
|
public class ApiUtil {
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
try {
|
try {
|
||||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import java.io.IOException;
|
|||||||
public class ApiUtil {
|
public class ApiUtil {
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
try {
|
try {
|
||||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import java.io.IOException;
|
|||||||
public class ApiUtil {
|
public class ApiUtil {
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
try {
|
try {
|
||||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import java.io.IOException;
|
|||||||
public class ApiUtil {
|
public class ApiUtil {
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
try {
|
try {
|
||||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import java.io.IOException;
|
|||||||
public class ApiUtil {
|
public class ApiUtil {
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
try {
|
try {
|
||||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import java.io.IOException;
|
|||||||
public class ApiUtil {
|
public class ApiUtil {
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
try {
|
try {
|
||||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import java.io.IOException;
|
|||||||
public class ApiUtil {
|
public class ApiUtil {
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
try {
|
try {
|
||||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import java.io.IOException;
|
|||||||
public class ApiUtil {
|
public class ApiUtil {
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
try {
|
try {
|
||||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import java.io.IOException;
|
|||||||
public class ApiUtil {
|
public class ApiUtil {
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
try {
|
try {
|
||||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import java.io.IOException;
|
|||||||
public class ApiUtil {
|
public class ApiUtil {
|
||||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
try {
|
try {
|
||||||
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||||
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.addHeader("Content-Type", contentType);
|
||||||
|
res.getWriter().print(example);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user