Compare commits

5 Commits

Author SHA1 Message Date
76de19f903 Update template/pom.xml 2025-01-23 09:50:45 +08:00
4b2ceb767b Update template/pom.xml 2025-01-23 09:49:21 +08:00
fe57fa01a2 Update template/pom.xml 2025-01-11 08:42:30 +08:00
5da7be6307 Update template/pom.xml 2025-01-09 14:28:14 +08:00
48747d2cc2 Update template/.gitignore 2024-12-31 18:37:45 +08:00
2 changed files with 4 additions and 27 deletions

View File

@@ -1,42 +1,20 @@
package com.vs;
import com.vs.common.util.rpc.handler.CustomArgumentResolver;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.annotation.MapMethodProcessor;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.ViewNameMethodReturnValueHandler;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@Configuration
public class VSResponseHandlerConfig implements WebMvcConfigurer {
private boolean useHandler = true;
RequestMappingHandlerAdapter requestMappingHandlerAdapter;
void init() {
List<HandlerMethodReturnValueHandler> returnValueHandlers = this.requestMappingHandlerAdapter.getReturnValueHandlers();
Iterator<HandlerMethodReturnValueHandler> iterator = returnValueHandlers.iterator();
List<HandlerMethodReturnValueHandler> newProcessors = new ArrayList<>();
while (iterator.hasNext()) {
HandlerMethodReturnValueHandler next = iterator.next();
//在controller中直接返回map不被默认的MapMethodProcessor拦截
if (next instanceof MapMethodProcessor ||
//在controller中直接返回String不被默认的ViewNameMethodReturnValueHandler拦截
next instanceof ViewNameMethodReturnValueHandler) {
continue;
} else {
newProcessors.add(next);
}
}
this.requestMappingHandlerAdapter.setReturnValueHandlers(newProcessors);
}
@Value("${com.toco.response.handler:true}")
private boolean useHandler;
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {

View File

@@ -126,4 +126,3 @@ essql.scheme={{ .elasticsearch_scheme }}
base.package=com.insigma;{{.groupId}}
cross.domain.headers=application-id
spring.devtools.restart.exclude={{.packagePath}}/**