update structure

This commit is contained in:
Shaun Chyxion 2017-06-18 23:40:33 +08:00
parent 21f6bb62d2
commit 42338ec447
44 changed files with 263 additions and 106 deletions

18
pom.xml
View File

@ -21,8 +21,8 @@
<properties> <properties>
<maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target> <maven.compiler.target>1.6</maven.compiler.target>
<spring.version>4.3.7.RELEASE</spring.version> <spring.version>4.3.8.RELEASE</spring.version>
<spring-boot.version>1.5.2.RELEASE</spring-boot.version> <spring-boot.version>1.5.3.RELEASE</spring-boot.version>
<slf4j.version>1.7.23</slf4j.version> <slf4j.version>1.7.23</slf4j.version>
<log4j.version>2.7</log4j.version> <log4j.version>2.7</log4j.version>
<shiro.version>1.3.2</shiro.version> <shiro.version>1.3.2</shiro.version>
@ -53,8 +53,9 @@
<module>tigon-mybatis</module> <module>tigon-mybatis</module>
<module>tigon-sequence</module> <module>tigon-sequence</module>
<module>tigon-redis</module> <module>tigon-redis</module>
<module>tigon-mybatis-redis-cache</module> <module>tigon-mybatis-cache-redis</module>
<module>tigon-shiro-redis-cache</module> <module>tigon-shiro-cache</module>
<module>tigon-shiro-cache-redis</module>
<module>tigon-webmvc-core</module> <module>tigon-webmvc-core</module>
<module>tigon-webmvc-spring-boot</module> <module>tigon-webmvc-spring-boot</module>
<module>tigon-webmvc-war</module> <module>tigon-webmvc-war</module>
@ -114,12 +115,17 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.chyxion.tigon</groupId> <groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-mybatis-redis-cache</artifactId> <artifactId>tigon-mybatis-cache-redis</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.chyxion.tigon</groupId> <groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-shiro-redis-cache</artifactId> <artifactId>tigon-shiro-cache-redis</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-shiro-cache</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -206,7 +206,7 @@ public class CodeGenServiceSupport implements CodeGenService {
// service interface // service interface
fmDataModel.put("baseServiceName", BaseCrudService.class.getSimpleName()); fmDataModel.put("baseServiceName", BaseCrudService.class.getSimpleName());
fmDataModel.put("baseServiceFullName", BaseService.class.getName()); fmDataModel.put("baseServiceFullName", BaseService.class.getName());
// server support // server shiro
fmDataModel.put("baseServiceSupportName", BaseCrudServiceSupport.class.getSimpleName()); fmDataModel.put("baseServiceSupportName", BaseCrudServiceSupport.class.getSimpleName());
fmDataModel.put("baseServiceSupportFullName", BaseCrudServiceSupport.class.getName()); fmDataModel.put("baseServiceSupportFullName", BaseCrudServiceSupport.class.getName());

View File

@ -35,14 +35,14 @@ public class ServiceCodeGen extends CodeGenerator {
codeDir + pkgDir + codeDir + pkgDir +
"/service/" + model + "Service.java")); "/service/" + model + "Service.java"));
// support // shiro
strRtn +=";"; strRtn +=";";
strRtn += render(new CodeGenArgs( strRtn += render(new CodeGenArgs(
CodeGenArgs.TARGET_SERVICE_SUPPORT, CodeGenArgs.TARGET_SERVICE_SUPPORT,
"/codegen/service-support.ftl", "/codegen/service-support.ftl",
dataModel, dataModel,
codeDir + pkgDir + codeDir + pkgDir +
"/service/support/" + model + "ServiceSupport.java" "/service/shiro/" + model + "ServiceSupport.java"
)); ));
return strRtn; return strRtn;
} }

View File

@ -15756,7 +15756,7 @@ Ext.define('Ext.XTemplateCompiler', {
* *
* - Autofilling arrays using templates and sub-templates * - Autofilling arrays using templates and sub-templates
* - Conditional processing with basic comparison operators * - Conditional processing with basic comparison operators
* - Basic math function support * - Basic math function shiro
* - Execute arbitrary inline code with special built-in template variables * - Execute arbitrary inline code with special built-in template variables
* - Custom member functions * - Custom member functions
* - Many special tags and built-in operators that aren't defined as part of the API, but are supported in the templates that can be created * - Many special tags and built-in operators that aren't defined as part of the API, but are supported in the templates that can be created
@ -15930,7 +15930,7 @@ Ext.define('Ext.XTemplateCompiler', {
* "<tpl if='name == \"Don\"'>Hello</tpl>" * "<tpl if='name == \"Don\"'>Hello</tpl>"
* ); * );
* *
* # Basic math support * # Basic math shiro
* *
* The following basic math operators may be applied directly on numeric data values: * The following basic math operators may be applied directly on numeric data values:
* *
@ -32784,7 +32784,7 @@ Ext.define('Ext.data.Connection', {
xdr = new XDomainRequest(); xdr = new XDomainRequest();
} else { } else {
Ext.Error.raise({ Ext.Error.raise({
msg: 'Your browser does not support CORS' msg: 'Your browser does not shiro CORS'
}); });
} }

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,15 @@
package me.chyxion.tigon.format.annotation;
import java.lang.annotation.*;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Jun 18, 2017 23:32:45
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
public @interface Trim {
}

View File

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"> http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>tigon-mybatis-redis-cache</artifactId> <artifactId>tigon-mybatis-cache-redis</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Tigon MyBatis Redis Cache</name> <name>Tigon MyBatis Redis Cache</name>
<description>Tigon MyBatis Redis Cache</description> <description>Tigon MyBatis Redis Cache</description>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>tigon-shiro-cache-redis</artifactId>
<name>Tigon Shiro Cache Redis</name>
<packaging>jar</packaging>
<parent>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-shiro-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<!-- shiro -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package me.chyxion.tigon.shiro.cache.support; package me.chyxion.tigon.shiro.cache.shiro;
import java.util.Set; import java.util.Set;
import org.slf4j.Logger; import org.slf4j.Logger;

View File

@ -4,5 +4,5 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"> http://www.springframework.org/schema/beans/spring-beans.xsd">
<description>Tigon Shiro Redis Cache</description> <description>Tigon Shiro Redis Cache</description>
<bean class="me.chyxion.tigon.shiro.cache.support.UserIdKeyRedisSessionCache" /> <bean class="me.chyxion.tigon.shiro.cache.shiro.UserIdKeyRedisSessionCache" />
</beans> </beans>

View File

@ -0,0 +1 @@
# tigon-shiro-redis-cache

View File

@ -4,8 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"> http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>tigon-shiro-redis-cache</artifactId> <artifactId>tigon-shiro-cache</artifactId>
<name>Tigon Shiro Redis Cache</name> <name>Tigon Shiro Cache</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<parent> <parent>

View File

@ -0,0 +1,17 @@
package me.chyxion.tigon.shiro;
import org.junit.Test;
/**
* @version 0.0.1
* @since 0.0.1
* @author chyxion <br>
* chyxion@163.com <br>
* Mar 14, 2015 3:03:57 PM
*/
public class TestDriver {
@Test
public void test() {
}
}

View File

@ -0,0 +1,13 @@
log4j.rootLogger=${log.root}
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.Encoding=utf-8
log4j.appender.console.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%F:%L] %m%n
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%F:%L] %m%n
log4j.appender.file.File=${log.dir}/${project.artifactId}-test.log
log4j.appender.file.Encoding=utf-8

View File

@ -27,7 +27,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.chyxion.tigon</groupId> <groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-shiro-redis-cache</artifactId> <artifactId>tigon-shiro-cache</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.chyxion.tigon</groupId> <groupId>me.chyxion.tigon</groupId>

View File

@ -1,8 +1,7 @@
package me.chyxion.tigon.shiro; package me.chyxion.tigon.shiro;
import org.slf4j.Logger;
import java.io.Serializable; import java.io.Serializable;
import org.slf4j.LoggerFactory; import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.cache.Cache; import org.apache.shiro.cache.Cache;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import org.apache.shiro.cache.MapCache; import org.apache.shiro.cache.MapCache;
@ -23,8 +22,8 @@ import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
* chyxion@163.com <br> * chyxion@163.com <br>
* Sep 8, 2014 7:43:05 PM * Sep 8, 2014 7:43:05 PM
*/ */
@Slf4j
public class SessionDAOSupport extends EnterpriseCacheSessionDAO { public class SessionDAOSupport extends EnterpriseCacheSessionDAO {
private static final Logger log = LoggerFactory.getLogger(SessionDAOSupport.class);
@Autowired(required = false) @Autowired(required = false)
private Cache<Serializable, Session> sessionCache; private Cache<Serializable, Session> sessionCache;
@Autowired @Autowired

View File

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>${project.name}</display-name>
<description>${project.description}</description>
<!-- Your Configurations Are Here! -->
</web-app>

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- //
帐号92dd46acd0fe11e4
密码F92dd46acd0fe11e4
地址92dd46acd0fe11e4.m.cnhza.kvstore.aliyuncs.com
端口6379
-->
<!-- <bean class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" -->
<!-- p:host-name="127.0.0.1" -->
<!-- p:password="0211" /> -->
<bean class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:host-name="92dd46acd0fe11e4.m.cnhza.kvstore.aliyuncs.com"
p:port="6379"
p:password="92dd46acd0fe11e4-F92dd46acd0fe11e4" />
<bean class="org.springframework.data.redis.core.StringRedisTemplate" autowire="constructor" />
<bean class="org.springframework.data.redis.core.RedisTemplate" autowire="byType">
<!-- <property name="connectionFactory" ref="jedisConnectionFactory" /> -->
<property name="keySerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
</property>
<property name="hashKeySerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
</property>
<property name="valueSerializer">
<bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
</property>
<property name="hashValueSerializer">
<bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
</property>
</bean>
</beans>

View File

@ -23,12 +23,13 @@ import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import me.chyxion.tigon.webmvc.converter.StringToDateTypeConverter; import me.chyxion.tigon.webmvc.converter.StringToDateTypeConverter;
import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver; import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4; import me.chyxion.tigon.webmvc.formatter.TrimAnnotationFormatterFactory;
import me.chyxion.tigon.webmvc.converter.StringToJSONArrayTypeConverter; import me.chyxion.tigon.webmvc.converter.StringToJSONArrayTypeConverter;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4;
import me.chyxion.tigon.webmvc.converter.StringToJSONObjectTypeConverter; import me.chyxion.tigon.webmvc.converter.StringToJSONObjectTypeConverter;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler; import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
import me.chyxion.tigon.webmvc.formatter.EmptyToNullAnnotationFormatterFactory; import me.chyxion.tigon.webmvc.formatter.EmptyToNullAnnotationFormatterFactory;
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
/** /**
* @author Shaun Chyxion <br> * @author Shaun Chyxion <br>
@ -59,6 +60,7 @@ public class TigonWebMvcConfiguration extends WebMvcConfigurationSupport {
// formatters // formatters
registry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory()); registry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
registry.addFormatterForFieldAnnotation(new EmptyToNullAnnotationFormatterFactory()); registry.addFormatterForFieldAnnotation(new EmptyToNullAnnotationFormatterFactory());
registry.addFormatterForFieldAnnotation(new TrimAnnotationFormatterFactory());
} }
/** /**

View File

@ -0,0 +1,54 @@
package me.chyxion.tigon.webmvc.formatter;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
import org.springframework.format.Parser;
import org.springframework.format.Printer;
import me.chyxion.tigon.format.annotation.Trim;
import org.springframework.format.AnnotationFormatterFactory;
import org.springframework.context.support.EmbeddedValueResolutionSupport;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Jun 18, 2017 23:35:10
*/
public class TrimAnnotationFormatterFactory
extends EmbeddedValueResolutionSupport
implements AnnotationFormatterFactory<Trim> {
private static final Set<Class<?>> FIELD_TYPES;
static {
Set<Class<?>> fieldTypes = new HashSet<Class<?>>(1);
fieldTypes.add(String.class);
FIELD_TYPES = Collections.unmodifiableSet(fieldTypes);
}
/**
* {@inheritDoc}
*/
@Override
public Set<Class<?>> getFieldTypes() {
return FIELD_TYPES;
}
/**
* {@inheritDoc}
*/
@Override
public Printer<?> getPrinter(Trim annotation,
Class<?> fieldType) {
return new TrimFormatter();
}
/**
* {@inheritDoc}
*/
@Override
public Parser<?> getParser(Trim annotation,
Class<?> fieldType) {
return new TrimFormatter();
}
}

View File

@ -0,0 +1,30 @@
package me.chyxion.tigon.webmvc.formatter;
import java.util.Locale;
import java.text.ParseException;
import org.springframework.format.Formatter;
import org.apache.commons.lang3.StringUtils;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Jun 18, 2017 23:34:48
*/
public class TrimFormatter implements Formatter<String> {
/**
* {@inheritDoc}
*/
@Override
public String print(String text, Locale locale) {
return text;
}
/**
* {@inheritDoc}
*/
@Override
public String parse(String text, Locale locale) throws ParseException {
return StringUtils.isNotEmpty(text) ? text.trim() : null;
}
}

View File

@ -15,19 +15,19 @@
<bean class="me.chyxion.tigon.webmvc.exception.DefaultExceptionResolver" /> <bean class="me.chyxion.tigon.webmvc.exception.DefaultExceptionResolver" />
<bean class="me.chyxion.tigon.webmvc.DefaultViewResolver" p:order="64" /> <bean class="me.chyxion.tigon.webmvc.DefaultViewResolver" p:order="64" />
<bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor" /> <!--<bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor" />-->
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"> <!--<bean id="mvcValidator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">-->
<property name="validationMessageSource"> <!--<property name="validationMessageSource">-->
<bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" <!--<bean class="org.springframework.context.shiro.ReloadableResourceBundleMessageSource"-->
p:fallbackToSystemLocale="true" <!--p:fallbackToSystemLocale="true"-->
p:useCodeAsDefaultMessage="false" <!--p:useCodeAsDefaultMessage="false"-->
p:defaultEncoding="UTF-8"> <!--p:defaultEncoding="UTF-8">-->
<property name="basenames"> <!--<property name="basenames">-->
<list> <!--<list>-->
<value>classpath:i18n/messages</value> <!--<value>classpath:i18n/messages</value>-->
</list> <!--</list>-->
</property> <!--</property>-->
</bean> <!--</bean>-->
</property> <!--</property>-->
</bean> <!--</bean>-->
</beans> </beans>

View File

@ -9,7 +9,6 @@ import org.springframework.http.MediaType;
import org.springframework.util.PathMatcher; import org.springframework.util.PathMatcher;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.CharEncoding; import org.apache.commons.lang3.CharEncoding;
import org.springframework.validation.Validator;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.format.FormatterRegistry; import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.LocaleResolver;
@ -21,19 +20,20 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.ImportResource;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.mvc.WebContentInterceptor;
import org.springframework.web.servlet.i18n.CookieLocaleResolver; import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import me.chyxion.tigon.webmvc.converter.StringToDateTypeConverter; import me.chyxion.tigon.webmvc.converter.StringToDateTypeConverter;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver; import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
import me.chyxion.tigon.webmvc.formatter.TrimAnnotationFormatterFactory;
import me.chyxion.tigon.webmvc.converter.StringToJSONArrayTypeConverter; import me.chyxion.tigon.webmvc.converter.StringToJSONArrayTypeConverter;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4; import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4;
import me.chyxion.tigon.webmvc.converter.StringToJSONObjectTypeConverter; import me.chyxion.tigon.webmvc.converter.StringToJSONObjectTypeConverter;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler; import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
import me.chyxion.tigon.webmvc.formatter.EmptyToNullAnnotationFormatterFactory; import me.chyxion.tigon.webmvc.formatter.EmptyToNullAnnotationFormatterFactory;
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.web.servlet.mvc.WebContentInterceptor;
/** /**
* @author Shaun Chyxion <br> * @author Shaun Chyxion <br>
@ -46,8 +46,6 @@ import org.springframework.web.servlet.mvc.WebContentInterceptor;
@ConditionalOnWebApplication @ConditionalOnWebApplication
@ImportResource("classpath*:spring/spring-*.xml") @ImportResource("classpath*:spring/spring-*.xml")
public class TigonWebMvcSpringBootConfiguration extends WebMvcConfigurerAdapter { public class TigonWebMvcSpringBootConfiguration extends WebMvcConfigurerAdapter {
@Autowired
private Validator validator;
@Autowired(required = false) @Autowired(required = false)
private List<TigonHandlerInterceptor> handlerInterceptors; private List<TigonHandlerInterceptor> handlerInterceptors;
@ -66,6 +64,7 @@ public class TigonWebMvcSpringBootConfiguration extends WebMvcConfigurerAdapter
// formatters // formatters
registry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory()); registry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
registry.addFormatterForFieldAnnotation(new EmptyToNullAnnotationFormatterFactory()); registry.addFormatterForFieldAnnotation(new EmptyToNullAnnotationFormatterFactory());
registry.addFormatterForFieldAnnotation(new TrimAnnotationFormatterFactory());
} }
/** /**
@ -156,14 +155,6 @@ public class TigonWebMvcSpringBootConfiguration extends WebMvcConfigurerAdapter
.addResourceLocations("/assets/", "classpath:webapp/assets/"); .addResourceLocations("/assets/", "classpath:webapp/assets/");
} }
/**
* {@inheritDoc}
*/
@Override
public Validator getValidator() {
return validator;
}
@Bean @Bean
public LocaleResolver localeResolver() { public LocaleResolver localeResolver() {
return new CookieLocaleResolver() { return new CookieLocaleResolver() {

View File

@ -74,4 +74,11 @@ public class SiteControllerTest {
params.put("gender", ""); params.put("gender", "");
t.print(t.post("/post", params)); t.print(t.post("/post", params));
} }
@Test
public void testRequired() {
Map<String, Object> params = new HashMap<String, Object>();
// params.put("param", "");
t.print(t.post("/required", params));
}
} }

View File

@ -12,6 +12,7 @@ import org.springframework.stereotype.Controller;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
/** /**
@ -21,12 +22,20 @@ import org.springframework.web.servlet.ModelAndView;
* chyxion@163.com <br> * chyxion@163.com <br>
* May 31, 2015 3:53:04 PM * May 31, 2015 3:53:04 PM
*/ */
@Validated
@Controller @Controller
public class SiteController { public class SiteController {
@RequestMapping("/") @RequestMapping("/")
public void index() { public void index() {
}
@RequestMapping("/required")
public String required(
@NotBlank
@RequestParam("param") String param) {
return param;
} }
@RequestMapping("/raw") @RequestMapping("/raw")
@ -82,6 +91,7 @@ public class SiteController {
private String id; private String id;
@NotBlank @NotBlank
private String name; private String name;
@NotBlank
private String gender; private String gender;
/** /**