update structure
This commit is contained in:
parent
21f6bb62d2
commit
42338ec447
18
pom.xml
18
pom.xml
@ -21,8 +21,8 @@
|
||||
<properties>
|
||||
<maven.compiler.source>1.6</maven.compiler.source>
|
||||
<maven.compiler.target>1.6</maven.compiler.target>
|
||||
<spring.version>4.3.7.RELEASE</spring.version>
|
||||
<spring-boot.version>1.5.2.RELEASE</spring-boot.version>
|
||||
<spring.version>4.3.8.RELEASE</spring.version>
|
||||
<spring-boot.version>1.5.3.RELEASE</spring-boot.version>
|
||||
<slf4j.version>1.7.23</slf4j.version>
|
||||
<log4j.version>2.7</log4j.version>
|
||||
<shiro.version>1.3.2</shiro.version>
|
||||
@ -53,8 +53,9 @@
|
||||
<module>tigon-mybatis</module>
|
||||
<module>tigon-sequence</module>
|
||||
<module>tigon-redis</module>
|
||||
<module>tigon-mybatis-redis-cache</module>
|
||||
<module>tigon-shiro-redis-cache</module>
|
||||
<module>tigon-mybatis-cache-redis</module>
|
||||
<module>tigon-shiro-cache</module>
|
||||
<module>tigon-shiro-cache-redis</module>
|
||||
<module>tigon-webmvc-core</module>
|
||||
<module>tigon-webmvc-spring-boot</module>
|
||||
<module>tigon-webmvc-war</module>
|
||||
@ -114,12 +115,17 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.chyxion.tigon</groupId>
|
||||
<artifactId>tigon-mybatis-redis-cache</artifactId>
|
||||
<artifactId>tigon-mybatis-cache-redis</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<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>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -206,7 +206,7 @@ public class CodeGenServiceSupport implements CodeGenService {
|
||||
// service interface
|
||||
fmDataModel.put("baseServiceName", BaseCrudService.class.getSimpleName());
|
||||
fmDataModel.put("baseServiceFullName", BaseService.class.getName());
|
||||
// server support
|
||||
// server shiro
|
||||
fmDataModel.put("baseServiceSupportName", BaseCrudServiceSupport.class.getSimpleName());
|
||||
fmDataModel.put("baseServiceSupportFullName", BaseCrudServiceSupport.class.getName());
|
||||
|
||||
|
@ -35,14 +35,14 @@ public class ServiceCodeGen extends CodeGenerator {
|
||||
codeDir + pkgDir +
|
||||
"/service/" + model + "Service.java"));
|
||||
|
||||
// support
|
||||
// shiro
|
||||
strRtn +=";";
|
||||
strRtn += render(new CodeGenArgs(
|
||||
CodeGenArgs.TARGET_SERVICE_SUPPORT,
|
||||
"/codegen/service-support.ftl",
|
||||
dataModel,
|
||||
codeDir + pkgDir +
|
||||
"/service/support/" + model + "ServiceSupport.java"
|
||||
"/service/shiro/" + model + "ServiceSupport.java"
|
||||
));
|
||||
return strRtn;
|
||||
}
|
||||
|
@ -15756,7 +15756,7 @@ Ext.define('Ext.XTemplateCompiler', {
|
||||
*
|
||||
* - Autofilling arrays using templates and sub-templates
|
||||
* - Conditional processing with basic comparison operators
|
||||
* - Basic math function support
|
||||
* - Basic math function shiro
|
||||
* - Execute arbitrary inline code with special built-in template variables
|
||||
* - 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
|
||||
@ -15930,7 +15930,7 @@ Ext.define('Ext.XTemplateCompiler', {
|
||||
* "<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:
|
||||
*
|
||||
@ -32784,7 +32784,7 @@ Ext.define('Ext.data.Connection', {
|
||||
xdr = new XDomainRequest();
|
||||
} else {
|
||||
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
@ -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 {
|
||||
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
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-mybatis-redis-cache</artifactId>
|
||||
<artifactId>tigon-mybatis-cache-redis</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Tigon MyBatis Redis Cache</name>
|
||||
<description>Tigon MyBatis Redis Cache</description>
|
65
tigon-shiro-cache-redis/pom.xml
Normal file
65
tigon-shiro-cache-redis/pom.xml
Normal 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>
|
@ -1,4 +1,4 @@
|
||||
package me.chyxion.tigon.shiro.cache.support;
|
||||
package me.chyxion.tigon.shiro.cache.shiro;
|
||||
|
||||
import java.util.Set;
|
||||
import org.slf4j.Logger;
|
@ -4,5 +4,5 @@
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<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>
|
1
tigon-shiro-cache/README.md
Normal file
1
tigon-shiro-cache/README.md
Normal file
@ -0,0 +1 @@
|
||||
# tigon-shiro-redis-cache
|
@ -4,8 +4,8 @@
|
||||
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-redis-cache</artifactId>
|
||||
<name>Tigon Shiro Redis Cache</name>
|
||||
<artifactId>tigon-shiro-cache</artifactId>
|
||||
<name>Tigon Shiro Cache</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
@ -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() {
|
||||
}
|
||||
}
|
13
tigon-shiro-cache/src/test/resources/log4j.properties
Normal file
13
tigon-shiro-cache/src/test/resources/log4j.properties
Normal 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
|
||||
|
@ -27,7 +27,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.chyxion.tigon</groupId>
|
||||
<artifactId>tigon-shiro-redis-cache</artifactId>
|
||||
<artifactId>tigon-shiro-cache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.chyxion.tigon</groupId>
|
||||
|
@ -1,8 +1,7 @@
|
||||
package me.chyxion.tigon.shiro;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import java.io.Serializable;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.cache.Cache;
|
||||
import javax.annotation.PostConstruct;
|
||||
import org.apache.shiro.cache.MapCache;
|
||||
@ -23,8 +22,8 @@ import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
|
||||
* chyxion@163.com <br>
|
||||
* Sep 8, 2014 7:43:05 PM
|
||||
*/
|
||||
@Slf4j
|
||||
public class SessionDAOSupport extends EnterpriseCacheSessionDAO {
|
||||
private static final Logger log = LoggerFactory.getLogger(SessionDAOSupport.class);
|
||||
@Autowired(required = false)
|
||||
private Cache<Serializable, Session> sessionCache;
|
||||
@Autowired
|
||||
|
@ -1,3 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
@ -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>
|
@ -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>
|
@ -23,12 +23,13 @@ import org.springframework.web.servlet.i18n.CookieLocaleResolver;
|
||||
import me.chyxion.tigon.webmvc.converter.StringToDateTypeConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
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 com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4;
|
||||
import me.chyxion.tigon.webmvc.converter.StringToJSONObjectTypeConverter;
|
||||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
|
||||
import me.chyxion.tigon.webmvc.formatter.EmptyToNullAnnotationFormatterFactory;
|
||||
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
|
||||
|
||||
/**
|
||||
* @author Shaun Chyxion <br>
|
||||
@ -59,6 +60,7 @@ public class TigonWebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||
// formatters
|
||||
registry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
|
||||
registry.addFormatterForFieldAnnotation(new EmptyToNullAnnotationFormatterFactory());
|
||||
registry.addFormatterForFieldAnnotation(new TrimAnnotationFormatterFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -15,19 +15,19 @@
|
||||
<bean class="me.chyxion.tigon.webmvc.exception.DefaultExceptionResolver" />
|
||||
<bean class="me.chyxion.tigon.webmvc.DefaultViewResolver" p:order="64" />
|
||||
|
||||
<bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor" />
|
||||
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
|
||||
<property name="validationMessageSource">
|
||||
<bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
|
||||
p:fallbackToSystemLocale="true"
|
||||
p:useCodeAsDefaultMessage="false"
|
||||
p:defaultEncoding="UTF-8">
|
||||
<property name="basenames">
|
||||
<list>
|
||||
<value>classpath:i18n/messages</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
<!--<bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor" />-->
|
||||
<!--<bean id="mvcValidator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">-->
|
||||
<!--<property name="validationMessageSource">-->
|
||||
<!--<bean class="org.springframework.context.shiro.ReloadableResourceBundleMessageSource"-->
|
||||
<!--p:fallbackToSystemLocale="true"-->
|
||||
<!--p:useCodeAsDefaultMessage="false"-->
|
||||
<!--p:defaultEncoding="UTF-8">-->
|
||||
<!--<property name="basenames">-->
|
||||
<!--<list>-->
|
||||
<!--<value>classpath:i18n/messages</value>-->
|
||||
<!--</list>-->
|
||||
<!--</property>-->
|
||||
<!--</bean>-->
|
||||
<!--</property>-->
|
||||
<!--</bean>-->
|
||||
</beans>
|
||||
|
@ -9,7 +9,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.util.PathMatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.lang3.CharEncoding;
|
||||
import org.springframework.validation.Validator;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.format.FormatterRegistry;
|
||||
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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.web.servlet.mvc.WebContentInterceptor;
|
||||
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
|
||||
import me.chyxion.tigon.webmvc.converter.StringToDateTypeConverter;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
|
||||
import me.chyxion.tigon.webmvc.formatter.TrimAnnotationFormatterFactory;
|
||||
import me.chyxion.tigon.webmvc.converter.StringToJSONArrayTypeConverter;
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4;
|
||||
import me.chyxion.tigon.webmvc.converter.StringToJSONObjectTypeConverter;
|
||||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
|
||||
import me.chyxion.tigon.webmvc.formatter.EmptyToNullAnnotationFormatterFactory;
|
||||
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.web.servlet.mvc.WebContentInterceptor;
|
||||
|
||||
/**
|
||||
* @author Shaun Chyxion <br>
|
||||
@ -46,8 +46,6 @@ import org.springframework.web.servlet.mvc.WebContentInterceptor;
|
||||
@ConditionalOnWebApplication
|
||||
@ImportResource("classpath*:spring/spring-*.xml")
|
||||
public class TigonWebMvcSpringBootConfiguration extends WebMvcConfigurerAdapter {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
@Autowired(required = false)
|
||||
private List<TigonHandlerInterceptor> handlerInterceptors;
|
||||
|
||||
@ -66,6 +64,7 @@ public class TigonWebMvcSpringBootConfiguration extends WebMvcConfigurerAdapter
|
||||
// formatters
|
||||
registry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
|
||||
registry.addFormatterForFieldAnnotation(new EmptyToNullAnnotationFormatterFactory());
|
||||
registry.addFormatterForFieldAnnotation(new TrimAnnotationFormatterFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,14 +155,6 @@ public class TigonWebMvcSpringBootConfiguration extends WebMvcConfigurerAdapter
|
||||
.addResourceLocations("/assets/", "classpath:webapp/assets/");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Validator getValidator() {
|
||||
return validator;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LocaleResolver localeResolver() {
|
||||
return new CookieLocaleResolver() {
|
||||
|
@ -74,4 +74,11 @@ public class SiteControllerTest {
|
||||
params.put("gender", "");
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
@ -21,6 +22,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
* chyxion@163.com <br>
|
||||
* May 31, 2015 3:53:04 PM
|
||||
*/
|
||||
@Validated
|
||||
@Controller
|
||||
public class SiteController {
|
||||
|
||||
@ -29,6 +31,13 @@ public class SiteController {
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/required")
|
||||
public String required(
|
||||
@NotBlank
|
||||
@RequestParam("param") String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
@RequestMapping("/raw")
|
||||
public Map<String, Object> raw() {
|
||||
Map<String, Object> mapRaw = new HashMap<String, Object>();
|
||||
@ -82,6 +91,7 @@ public class SiteController {
|
||||
private String id;
|
||||
@NotBlank
|
||||
private String name;
|
||||
@NotBlank
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user