作者 朱兆平

优化基于win或者linux的乱码返回方法

FROM java:8u111
VOLUME /tmp
ENV PINPOINT_VERSION="2.3.1"
ENV AGENT_ID="gateway-Utf8-master1.0"
ENV APP_NAME="gateway-Utf8"
ENV JAVA_OPTS="-javaagent:/pinpoint-agent/pinpoint-bootstrap-${PINPOINT_VERSION}.jar -Dpinpoint.agentId=${AGENT_ID} -Dpinpoint.applicationName=${APP_NAME} -Dspring.profiles.active=${SPRING_PROFILES}"
ADD *.jar app.jar
EXPOSE 12343
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
#ENTRYPOINT ["java","$JAVA_OPTS","-jar","/app.jar"]
ENTRYPOINT java $JAVA_OPTS -jar /app.jar
# Ubuntu 时区
... ...
... ... @@ -64,8 +64,11 @@ public class WrapperResponseGlobalFilter implements GlobalFilter, Ordered {
return exchange.getResponse().setComplete();
}
ServerHttpResponse response = exchange.getResponse();
DataBufferFactory bufferFactory = response.bufferFactory();
// ServerHttpResponse response = exchange.getResponse();
// DataBufferFactory bufferFactory = response.bufferFactory();
//----------------------------------old
// ServerHttpResponseDecorator decorator = new ServerHttpResponseDecorator(response) {
// @Override
// public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
... ... @@ -93,18 +96,22 @@ public class WrapperResponseGlobalFilter implements GlobalFilter, Ordered {
// return super.writeWith(body);
// }
// };
ServerHttpResponseDecorator decoratedResponse= new UTF8ServerHttpResponseDecorator(response);
if (DEFAULT_SYSTEM.equals(systemInfo)){
decoratedResponse= new UTF8ServerHttpResponseDecorator(response);
}else {
decoratedResponse= new GBKServerHttpResponseDecorator(response);
}
//----------------------------------old
/**
* 取消返回数据的修改
*/
// ServerHttpResponseDecorator decoratedResponse= new UTF8ServerHttpResponseDecorator(response);
// if (DEFAULT_SYSTEM.equals(systemInfo)){
// decoratedResponse= new UTF8ServerHttpResponseDecorator(response);
// }else {
// decoratedResponse= new GBKServerHttpResponseDecorator(response);
// }
//
return chain.filter(exchange.mutate().response(decoratedResponse).build());
//
// return chain.filter(exchange);
// return chain.filter(exchange.mutate().response(decoratedResponse).build());
return chain.filter(exchange);
}
@Override
... ...
${AnsiColor.YELLOW}
##################*CETC-TIANBO*#########################
.::::.
.::::::::.
:::::::::::
..:::::::::::'
'::::::::::::'
.::::::::::
'::::::::::::::..
..::::::::::::.
``::::::::::::::::
::::``:::::::::' .:::.
::::' ':::::' .::::::::.
.::::' :::: .:::::::'::::.
.:::' ::::: .:::::::::' ':::::.
.::' :::::.:::::::::' ':::::.
.::' ::::::::::::::' ``::::.
...::: ::::::::::::' ``::.
```` ':. ':::::::::' ::::..
'.:::::' ':'````..
#########################################################
##################*CETC-TIANBO*###################################
|
|
|
_|_
/___\
/_____\
/oo oo\
\___________________________\ /___________________________/
`-----------|------|--------\_____/--------|------|-----------'
( ) ( ) O|OOo|oOO|O ( ) ( )
###################################################################
... ... @@ -27,4 +18,4 @@ ${AnsiColor.YELLOW}
==================================================
Application Info:${application.title}
ver:${application.version}
Powered by:Spring Boot ${spring-boot.version}
\ No newline at end of file
Powered by:Spring Boot ${spring-boot.version}
... ...