aboutsummaryrefslogtreecommitdiff
path: root/juick-spring-www/src/main/java/com/juick/www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-12-16 15:41:14 +0300
committerGravatar Vitaly Takmazov2016-12-16 15:41:14 +0300
commit300a0439b2a6e26d9025247ef780c886616d4ae1 (patch)
treebcdb7613c2c5f37b870cbe18241894dba9428fae /juick-spring-www/src/main/java/com/juick/www
parent18a8595d2150edc92084c94b9dbb8f4309d3ed36 (diff)
CharEncoding.UTF_8
Diffstat (limited to 'juick-spring-www/src/main/java/com/juick/www')
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java3
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/configuration/WwwInitializer.java3
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java5
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java3
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/controllers/TagController.java7
5 files changed, 13 insertions, 8 deletions
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java
index 28a0f29a..4482dce1 100644
--- a/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java
+++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java
@@ -2,6 +2,7 @@ package com.juick.www.configuration;
import com.juick.www.HelpService;
import com.juick.www.WebApp;
+import org.apache.commons.lang3.CharEncoding;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCacheManager;
import org.springframework.cache.interceptor.KeyGenerator;
@@ -29,7 +30,7 @@ public class WebAppConfiguration {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasenames("messages", "errors");
- messageSource.setDefaultEncoding("UTF-8");
+ messageSource.setDefaultEncoding(CharEncoding.UTF_8);
messageSource.setFallbackToSystemLocale(false);
messageSource.setUseCodeAsDefaultMessage(true);
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwInitializer.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwInitializer.java
index edb9a9fc..33687983 100644
--- a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwInitializer.java
+++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwInitializer.java
@@ -2,6 +2,7 @@ package com.juick.www.configuration;
import com.juick.configuration.DataConfiguration;
import com.juick.configuration.SearchConfiguration;
+import org.apache.commons.lang3.CharEncoding;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
@@ -43,7 +44,7 @@ public class WwwInitializer extends AbstractAnnotationConfigDispatcherServletIni
super.onStartup(servletContext);
FilterRegistration.Dynamic registration = servletContext.addFilter(
- "encodingFilter", new CharacterEncodingFilter("UTF-8", true));
+ "encodingFilter", new CharacterEncodingFilter(CharEncoding.UTF_8, true));
registration.addMappingForUrlPatterns(null, true, "/*");
}
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
index 15f85c9a..5cd251e6 100644
--- a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
+++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.juick.www.formatter.SpringDateFormatter;
import nz.net.ultraq.thymeleaf.LayoutDialect;
import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.CharEncoding;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -55,7 +56,7 @@ public class WwwServletConfiguration extends WebMvcConfigurationSupport {
// templates to be automatically updated when modified.
templateResolver.setCacheable(true);
- templateResolver.setCharacterEncoding("UTF-8");
+ templateResolver.setCharacterEncoding(CharEncoding.UTF_8);
return templateResolver;
}
@@ -83,7 +84,7 @@ public class WwwServletConfiguration extends WebMvcConfigurationSupport {
public ThymeleafViewResolver viewResolver() {
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
viewResolver.setTemplateEngine(templateEngine());
- viewResolver.setCharacterEncoding("UTF-8");
+ viewResolver.setCharacterEncoding(CharEncoding.UTF_8);
viewResolver.addStaticVariable(
"showSape", BooleanUtils.toBoolean(env.getProperty("template.showSape", "true")));
diff --git a/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java b/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
index ffc64221..54d83b61 100644
--- a/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
+++ b/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
@@ -7,6 +7,7 @@ import com.juick.service.TagService;
import com.juick.service.UserService;
import com.juick.util.UserUtils;
import com.juick.www.util.EncodeUtils;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.MessageSource;
@@ -48,7 +49,7 @@ public class IndexController {
ModelMap model) throws IOException {
if (paramTagStr.isPresent())
- return "redirect:/tag/" + URLEncoder.encode(paramTagStr.get(), "UTF-8");
+ return "redirect:/tag/" + URLEncoder.encode(paramTagStr.get(), CharEncoding.UTF_8);
if (StringUtils.isNotEmpty(paramSearch) && paramSearch.length() > 64)
paramSearch = "";
diff --git a/juick-spring-www/src/main/java/com/juick/www/controllers/TagController.java b/juick-spring-www/src/main/java/com/juick/www/controllers/TagController.java
index 69688513..8c4ab46d 100644
--- a/juick-spring-www/src/main/java/com/juick/www/controllers/TagController.java
+++ b/juick-spring-www/src/main/java/com/juick/www/controllers/TagController.java
@@ -9,6 +9,7 @@ import com.juick.service.TagService;
import com.juick.service.UserService;
import com.juick.util.UserUtils;
import com.juick.www.helpers.QueryString;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@@ -51,13 +52,13 @@ public class TagController {
throw new HttpNotFoundException();
} else if (paramTag.SynonymID > 0 && paramTag.TID != paramTag.SynonymID) {
com.juick.Tag synTag = tagService.getTag(paramTag.SynonymID);
- String url = "/tag/" + URLEncoder.encode(synTag.getName(), "UTF-8");
+ String url = "/tag/" + URLEncoder.encode(synTag.getName(), CharEncoding.UTF_8);
if (queryString.isPresent()) {
url += "?" + queryString.get();
}
return "redirect:" + url;
} else if (!paramTag.getName().equals(paramTagStr)) {
- String url = "/tag/" + URLEncoder.encode(paramTag.getName(), "UTF-8");
+ String url = "/tag/" + URLEncoder.encode(paramTag.getName(), CharEncoding.UTF_8);
if (queryString.isPresent()) {
url += "?" + queryString.get();
}
@@ -97,7 +98,7 @@ public class TagController {
}).collect(Collectors.toList())
);
if (mids.size() >= 20) {
- String nextpage = "/tag/" + URLEncoder.encode(paramTag.getName(), "UTF-8") + "?before=" + mids.get(mids.size() - 1);
+ String nextpage = "/tag/" + URLEncoder.encode(paramTag.getName(), CharEncoding.UTF_8) + "?before=" + mids.get(mids.size() - 1);
model.addAttribute("nextpage", nextpage);
}
model.addAttribute("tags", tagService.getPopularTags());