Commit 316885a3 by fsn

主页显示问题解决

parent 3ecf4215
......@@ -13,6 +13,6 @@ public class GunsApplication {
public static void main(String[] args) {
SpringApplication.run(GunsApplication.class, args);
logger.info("PortalApplication is sussess!");
logger.info("GunsApplication is sussess!");
}
}
package com.stylefeng.guns.config;
import com.stylefeng.guns.core.intercept.SessionInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 保留类,如果控制器需要些aop在这里写
*
* @author fengshuonan
* @date 2016年11月12日 下午4:48:10
*/
@Configuration
public class ControllerAopConfig {
/**
* session的拦截器,用在非controller层调用session
*/
@Bean
public SessionInterceptor sessionInterceptor() {
return new SessionInterceptor();
}
}
package com.stylefeng.guns.config;
import net.sf.ehcache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
/**
* ehcache缓存的配置
*
* @author fengshuonan
* @date 2017-04-24 20:41
*/
@Configuration
@EnableCaching
public class EhcacheConfig {
@Bean
public EhCacheCacheManager cacheManager(CacheManager cacheManager){
return new EhCacheCacheManager(cacheManager);
}
@Bean
public EhCacheManagerFactoryBean ehcache(){
EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
return ehCacheManagerFactoryBean;
}
}
package com.stylefeng.guns.config;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Properties;
/**
* 验证码生成的配置
*
* @author fengshuonan
* @date 2017-05-20 22:03
*/
@Configuration
public class KaptchaConfig {
@Bean
public DefaultKaptcha kaptcha(){
Properties properties = new Properties();
properties.put("kaptcha.border","no");
properties.put("kaptcha.border.color","105,179,90");
properties.put("kaptcha.textproducer.font.color","blue");
properties.put("kaptcha.image.width","125");
properties.put("kaptcha.image.height","45");
properties.put("kaptcha.textproducer.font.size","45");
properties.put("kaptcha.session.key","code");
properties.put("kaptcha.textproducer.char.length","4");
properties.put("kaptcha.textproducer.font.names","宋体,楷体,微软雅黑");
Config config = new Config(properties);
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
}
package com.stylefeng.guns.config;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import net.sf.ehcache.CacheManager;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import project.config.web.beetl.BeetlConfiguration;
import java.util.Properties;
/**
* 其他bean的配置
*
* @author fengshuonan
* @date 2017-05-20 23:11
*/
@Configuration
public class OtherConfigs {
/**
* EhCache的配置
*/
@Bean
public EhCacheCacheManager cacheManager(CacheManager cacheManager) {
return new EhCacheCacheManager(cacheManager);
}
@Bean
public EhCacheManagerFactoryBean ehcache() {
EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
return ehCacheManagerFactoryBean;
}
/**
* 验证码生成相关
*/
@Bean
public DefaultKaptcha kaptcha() {
Properties properties = new Properties();
properties.put("kaptcha.border", "no");
properties.put("kaptcha.border.color", "105,179,90");
properties.put("kaptcha.textproducer.font.color", "blue");
properties.put("kaptcha.image.width", "125");
properties.put("kaptcha.image.height", "45");
properties.put("kaptcha.textproducer.font.size", "45");
properties.put("kaptcha.session.key", "code");
properties.put("kaptcha.textproducer.char.length", "4");
properties.put("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
Config config = new Config(properties);
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
/**
* beetl的配置
*/
@Bean(initMethod = "init")
public BeetlConfiguration beetlConfiguration() {
BeetlConfiguration beetlConfiguration = new BeetlConfiguration();
beetlConfiguration.setConfigFileResource(new ClassPathResource("beetl.properties"));
return beetlConfiguration;
}
}
......@@ -38,9 +38,6 @@ public class ShiroConfig {
//设置自定义Realm
securityManager.setRealm(this.shiroDbRealm());
//将缓存管理器,交给安全管理器
// securityManager.setCacheManager(this.shiroEhcacheManager());
//记住密码管理
securityManager.setRememberMeManager(rememberMeManager);
return securityManager;
......@@ -122,19 +119,6 @@ public class ShiroConfig {
}
/**
* 用户授权信息Cache, 采用EhCache
*
* @author fengshuonan
*/
// @Bean
// public EhCacheManager shiroEhcacheManager(){
// EhCacheManager ehCacheManager = new EhCacheManager();
// ehCacheManager.setCacheManagerConfigFile("classpath:ehcache.xml");
// ehCacheManager.setCacheManager(CacheManager.create());
// return ehCacheManager;
// }
/**
* 在方法中 注入 securityManager,进行代理控制
*
* @author fengshuonan
......
package com.stylefeng.guns.config;
import org.beetl.ext.spring.BeetlSpringViewResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import project.config.web.beetl.BeetlConfiguration;
/**
* spring mvc配置类
*
* @author fengshuonan
* @date 2016年11月12日 下午5:03:32
*/
@Configuration
public class SpringMvcConfig extends WebMvcConfigurerAdapter {
// beetl的配置
@Bean(initMethod = "init")
public BeetlConfiguration beetlConfiguration() {
BeetlConfiguration beetlConfiguration = new BeetlConfiguration();
beetlConfiguration.setConfigFileResource(new ClassPathResource("beetl.properties"));
return beetlConfiguration;
}
// beetl的视图解析器
@Bean
public BeetlSpringViewResolver beetlViewResolver() {
BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver();
beetlSpringViewResolver.setConfig(beetlConfiguration());
beetlSpringViewResolver.setContentType("text/html;charset=UTF-8");
beetlSpringViewResolver.setOrder(0);
return beetlSpringViewResolver;
}
}
......@@ -44,7 +44,7 @@ public class LogController extends BaseController {
/**
* 跳转到日志管理的首页
*/
@RequestMapping("")
@RequestMapping("/")
public String index() {
return PREFIX + "log.html";
}
......
//package project.config.web;
//
//import com.stylefeng.guns.core.intercept.SessionInterceptor;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.EnableAspectJAutoProxy;
//
///**
// * 保留类,如果控制器需要些aop在这里写
// *
// * @author fengshuonan
// * @date 2016年11月12日 下午4:48:10
// */
//@Configuration
//@EnableAspectJAutoProxy
//public class ControllerAopConfig {
//
// /**
// * session的拦截器,用在非controller层调用session
// */
// @Bean
// public SessionInterceptor sessionInterceptor() {
// return new SessionInterceptor();
// }
//
//}
package project.config.web;
import com.stylefeng.guns.core.intercept.SessionInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
/**
* 保留类,如果控制器需要些aop在这里写
*
* @author fengshuonan
* @date 2016年11月12日 下午4:48:10
*/
@Configuration
@EnableAspectJAutoProxy
public class ControllerAopConfig {
/**
* session的拦截器,用在非controller层调用session
*/
@Bean
public SessionInterceptor sessionInterceptor() {
return new SessionInterceptor();
}
}
//package project.config.web;
//
//import org.beetl.ext.spring.BeetlSpringViewResolver;
//import org.hibernate.validator.HibernateValidator;
//import org.springframework.context.annotation.*;
//import org.springframework.context.support.ReloadableResourceBundleMessageSource;
//import org.springframework.core.io.ClassPathResource;
//import org.springframework.http.MediaType;
//import org.springframework.http.converter.ByteArrayHttpMessageConverter;
//import org.springframework.http.converter.StringHttpMessageConverter;
//import org.springframework.validation.Validator;
//import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
//import org.springframework.web.multipart.MultipartResolver;
//import org.springframework.web.multipart.support.StandardServletMultipartResolver;
//import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
//import org.springframework.web.servlet.config.annotation.EnableWebMvc;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
//import project.config.web.beetl.BeetlConfiguration;
//
//import java.nio.charset.Charset;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * spring mvc配置类
// *
// * @author fengshuonan
// * @date 2016年11月12日 下午5:03:32
// */
//@Configuration
//@EnableWebMvc
//@ComponentScan(basePackages = {"com.stylefeng.guns.**.controller", "com.stylefeng.guns.common.controller"})
//@EnableAspectJAutoProxy
//@Import({ControllerAopConfig.class})
//public class SpringMvcConfig extends WebMvcConfigurerAdapter {
//
// // beetl的配置
// @Bean(initMethod = "init")
// public BeetlConfiguration beetlConfiguration() {
// BeetlConfiguration beetlConfiguration = new BeetlConfiguration();
// beetlConfiguration.setConfigFileResource(new ClassPathResource("beetl.properties"));
// return beetlConfiguration;
// }
//
// // beetl的视图解析器
// @Bean
// public BeetlSpringViewResolver beetlViewResolver() {
// BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver();
// beetlSpringViewResolver.setConfig(beetlConfiguration());
// beetlSpringViewResolver.setContentType("text/html;charset=UTF-8");
// beetlSpringViewResolver.setOrder(0);
// return beetlSpringViewResolver;
// }
//
// // 配置静态资源的处理,对静态资源的请求转发到servlet容器中默认的servlet上(对静态资源的请求不做处理)
// @Override
// public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
// configurer.enable();
// }
//
// // 文件上传用的resolver
// @Bean
// public MultipartResolver multipartResolver() {
// return new StandardServletMultipartResolver();
// }
//
// // 校验器的配置
// @Bean
// public LocalValidatorFactoryBean validator(ReloadableResourceBundleMessageSource messageSource) {
// LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
// localValidatorFactoryBean.setProviderClass(HibernateValidator.class);
// localValidatorFactoryBean.setValidationMessageSource(messageSource);
// return localValidatorFactoryBean;
// }
//
// // 国际化消息资源文件配置(本系统中主要用于显示/错误消息定制)
// @Bean
// public ReloadableResourceBundleMessageSource messageSource() {
// ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
// messageSource.setBasenames("classpath:org/hibernate/validator/ValidationMessages");
// messageSource.setUseCodeAsDefaultMessage(false);
// messageSource.setDefaultEncoding("UTF-8");
// messageSource.setCacheSeconds(60);
// return messageSource;
// }
//
// // 配置全局的验证器实例
// @Override
// public Validator getValidator() {
// return this.validator(messageSource());
// }
//
// // 配置spring mvc的拦截器
// @Override
// public void addInterceptors(InterceptorRegistry registry) {
//
// }
//
//
//
// @Bean
// public ByteArrayHttpMessageConverter byteMsgConverter() {
// return new ByteArrayHttpMessageConverter();
// }
//
// @Bean
// public StringHttpMessageConverter stringHttpMessageConverter() {
// StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(
// Charset.forName("UTF-8"));
// List<MediaType> list = new ArrayList<MediaType>();
// list.add(MediaType.TEXT_PLAIN);
// stringHttpMessageConverter.setSupportedMediaTypes(list);
// return stringHttpMessageConverter;
// }
//
//
//
//}
package project.config.web;
import org.beetl.ext.spring.BeetlSpringViewResolver;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.*;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.MediaType;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.validation.Validator;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.support.StandardServletMultipartResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import project.config.web.beetl.BeetlConfiguration;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
/**
* spring mvc配置类
*
* @author fengshuonan
* @date 2016年11月12日 下午5:03:32
*/
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"com.stylefeng.guns.**.controller", "com.stylefeng.guns.common.controller"})
@EnableAspectJAutoProxy
@Import({ControllerAopConfig.class})
public class SpringMvcConfig extends WebMvcConfigurerAdapter {
// beetl的配置
@Bean(initMethod = "init")
public BeetlConfiguration beetlConfiguration() {
BeetlConfiguration beetlConfiguration = new BeetlConfiguration();
beetlConfiguration.setConfigFileResource(new ClassPathResource("beetl.properties"));
return beetlConfiguration;
}
// beetl的视图解析器
@Bean
public BeetlSpringViewResolver beetlViewResolver() {
BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver();
beetlSpringViewResolver.setConfig(beetlConfiguration());
beetlSpringViewResolver.setContentType("text/html;charset=UTF-8");
beetlSpringViewResolver.setOrder(0);
return beetlSpringViewResolver;
}
// 配置静态资源的处理,对静态资源的请求转发到servlet容器中默认的servlet上(对静态资源的请求不做处理)
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
// 文件上传用的resolver
@Bean
public MultipartResolver multipartResolver() {
return new StandardServletMultipartResolver();
}
// 校验器的配置
@Bean
public LocalValidatorFactoryBean validator(ReloadableResourceBundleMessageSource messageSource) {
LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
localValidatorFactoryBean.setProviderClass(HibernateValidator.class);
localValidatorFactoryBean.setValidationMessageSource(messageSource);
return localValidatorFactoryBean;
}
// 国际化消息资源文件配置(本系统中主要用于显示/错误消息定制)
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasenames("classpath:org/hibernate/validator/ValidationMessages");
messageSource.setUseCodeAsDefaultMessage(false);
messageSource.setDefaultEncoding("UTF-8");
messageSource.setCacheSeconds(60);
return messageSource;
}
// 配置全局的验证器实例
@Override
public Validator getValidator() {
return this.validator(messageSource());
}
// 配置spring mvc的拦截器
@Override
public void addInterceptors(InterceptorRegistry registry) {
}
@Bean
public ByteArrayHttpMessageConverter byteMsgConverter() {
return new ByteArrayHttpMessageConverter();
}
@Bean
public StringHttpMessageConverter stringHttpMessageConverter() {
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(
Charset.forName("UTF-8"));
List<MediaType> list = new ArrayList<MediaType>();
list.add(MediaType.TEXT_PLAIN);
stringHttpMessageConverter.setSupportedMediaTypes(list);
return stringHttpMessageConverter;
}
}
......@@ -5,7 +5,23 @@
dynamicConfig="true" >
<diskStore path="java.io.tmpdir/ehcache"/>
<!-- 系统默认缓存 -->
<defaultCache
maxElementsInMemory="50000"
clearOnFlush="false"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
overflowToDisk="true"
diskSpoolBufferSizeMB="1024"
maxElementsOnDisk="100000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
</defaultCache>
<!-- 全局变量:永不过期-->
<cache name="CONSTANT"
maxElementsInMemory="50000"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment