aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/config/WebConfig.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/config/WebConfig.java')
-rw-r--r--src/main/java/com/juick/config/WebConfig.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/com/juick/config/WebConfig.java b/src/main/java/com/juick/config/WebConfig.java
index d736b863..136faea9 100644
--- a/src/main/java/com/juick/config/WebConfig.java
+++ b/src/main/java/com/juick/config/WebConfig.java
@@ -24,14 +24,18 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
+import com.juick.service.UserService;
+import com.juick.www.VisitorArgumentResolver;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.CacheControl;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.VersionResourceResolver;
@@ -45,6 +49,8 @@ public class WebConfig implements WebMvcConfigurer {
private String baseDir;
@Inject
private List<? extends Converter<?, ?>> converters;
+ @Inject
+ private UserService userService;
@Override
public void addFormatters(FormatterRegistry registry) {
@@ -52,7 +58,14 @@ public class WebConfig implements WebMvcConfigurer {
registry.addConverter(converter);
}
}
-
+ @Bean
+ HandlerMethodArgumentResolver visitorArgumentResolver() {
+ return new VisitorArgumentResolver(userService);
+ }
+ @Override
+ public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
+ resolvers.add(visitorArgumentResolver());
+ }
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
try {