aboutsummaryrefslogtreecommitdiff
path: root/juick-spring-www/src/main/java/com/juick/www/helpers
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-12-09 16:14:27 +0300
committerGravatar Vitaly Takmazov2016-12-09 16:14:27 +0300
commit559ae343aa72db04e12b94acfa0bec30ed9a11f1 (patch)
tree5832b97c6a6a4b565de15a474bae86059763d6bb /juick-spring-www/src/main/java/com/juick/www/helpers
parent22d30c3b50fe0ea4c18c45a4450fb1a8b1f1b1b8 (diff)
juick-spring-www: merge some work from develop branch, port some templates to Thymeleaf
Diffstat (limited to 'juick-spring-www/src/main/java/com/juick/www/helpers')
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/helpers/QueryString.java14
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/helpers/QueryStringResolver.java31
2 files changed, 45 insertions, 0 deletions
diff --git a/juick-spring-www/src/main/java/com/juick/www/helpers/QueryString.java b/juick-spring-www/src/main/java/com/juick/www/helpers/QueryString.java
new file mode 100644
index 00000000..0eb6c76f
--- /dev/null
+++ b/juick-spring-www/src/main/java/com/juick/www/helpers/QueryString.java
@@ -0,0 +1,14 @@
+package com.juick.www.helpers;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Created by vt on 22/03/16.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+public @interface QueryString {
+} \ No newline at end of file
diff --git a/juick-spring-www/src/main/java/com/juick/www/helpers/QueryStringResolver.java b/juick-spring-www/src/main/java/com/juick/www/helpers/QueryStringResolver.java
new file mode 100644
index 00000000..812c4497
--- /dev/null
+++ b/juick-spring-www/src/main/java/com/juick/www/helpers/QueryStringResolver.java
@@ -0,0 +1,31 @@
+package com.juick.www.helpers;
+
+import org.springframework.core.MethodParameter;
+import org.springframework.web.bind.support.WebDataBinderFactory;
+import org.springframework.web.context.request.NativeWebRequest;
+import org.springframework.web.method.support.HandlerMethodArgumentResolver;
+import org.springframework.web.method.support.ModelAndViewContainer;
+
+import javax.servlet.http.HttpServletRequest;
+import java.lang.annotation.Annotation;
+import java.util.Optional;
+
+public class QueryStringResolver implements HandlerMethodArgumentResolver {
+ @Override
+ public boolean supportsParameter(MethodParameter parameter) {
+ Annotation[] parameterAnnotations = parameter.getParameterAnnotations();
+ for (Annotation parameterAnnotation : parameterAnnotations) {
+ if (QueryString.class.isInstance(parameterAnnotation)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
+ HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
+ return Optional.ofNullable(request.getQueryString());
+ }
+} \ No newline at end of file