Commit 316885a3 by fsn

主页显示问题解决

parent 3ecf4215
...@@ -13,6 +13,6 @@ public class GunsApplication { ...@@ -13,6 +13,6 @@ public class GunsApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(GunsApplication.class, 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 { ...@@ -38,9 +38,6 @@ public class ShiroConfig {
//设置自定义Realm //设置自定义Realm
securityManager.setRealm(this.shiroDbRealm()); securityManager.setRealm(this.shiroDbRealm());
//将缓存管理器,交给安全管理器
// securityManager.setCacheManager(this.shiroEhcacheManager());
//记住密码管理 //记住密码管理
securityManager.setRememberMeManager(rememberMeManager); securityManager.setRememberMeManager(rememberMeManager);
return securityManager; return securityManager;
...@@ -122,19 +119,6 @@ public class ShiroConfig { ...@@ -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,进行代理控制 * 在方法中 注入 securityManager,进行代理控制
* *
* @author fengshuonan * @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 { ...@@ -44,7 +44,7 @@ public class LogController extends BaseController {
/** /**
* 跳转到日志管理的首页 * 跳转到日志管理的首页
*/ */
@RequestMapping("") @RequestMapping("/")
public String index() { public String index() {
return PREFIX + "log.html"; return PREFIX + "log.html";
} }
......
//package project.config.web; package project.config.web;
//
//import com.stylefeng.guns.core.intercept.SessionInterceptor; import com.stylefeng.guns.core.intercept.SessionInterceptor;
//import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
//
///** /**
// * 保留类,如果控制器需要些aop在这里写 * 保留类,如果控制器需要些aop在这里写
// * *
// * @author fengshuonan * @author fengshuonan
// * @date 2016年11月12日 下午4:48:10 * @date 2016年11月12日 下午4:48:10
// */ */
//@Configuration @Configuration
//@EnableAspectJAutoProxy @EnableAspectJAutoProxy
//public class ControllerAopConfig { public class ControllerAopConfig {
//
// /** /**
// * session的拦截器,用在非controller层调用session * session的拦截器,用在非controller层调用session
// */ */
// @Bean @Bean
// public SessionInterceptor sessionInterceptor() { public SessionInterceptor sessionInterceptor() {
// return new SessionInterceptor(); return new SessionInterceptor();
// } }
//
//} }
//package project.config.web; package project.config.web;
//
//import org.beetl.ext.spring.BeetlSpringViewResolver; import org.beetl.ext.spring.BeetlSpringViewResolver;
//import org.hibernate.validator.HibernateValidator; import org.hibernate.validator.HibernateValidator;
//import org.springframework.context.annotation.*; import org.springframework.context.annotation.*;
//import org.springframework.context.support.ReloadableResourceBundleMessageSource; import org.springframework.context.support.ReloadableResourceBundleMessageSource;
//import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
//import org.springframework.http.MediaType; import org.springframework.http.MediaType;
//import org.springframework.http.converter.ByteArrayHttpMessageConverter; import org.springframework.http.converter.ByteArrayHttpMessageConverter;
//import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter;
//import org.springframework.validation.Validator; import org.springframework.validation.Validator;
//import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
//import org.springframework.web.multipart.MultipartResolver; import org.springframework.web.multipart.MultipartResolver;
//import org.springframework.web.multipart.support.StandardServletMultipartResolver; import org.springframework.web.multipart.support.StandardServletMultipartResolver;
//import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
//import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.EnableWebMvc;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
//import project.config.web.beetl.BeetlConfiguration; import project.config.web.beetl.BeetlConfiguration;
//
//import java.nio.charset.Charset; import java.nio.charset.Charset;
//import java.util.ArrayList; import java.util.ArrayList;
//import java.util.List; import java.util.List;
//
///** /**
// * spring mvc配置类 * spring mvc配置类
// * *
// * @author fengshuonan * @author fengshuonan
// * @date 2016年11月12日 下午5:03:32 * @date 2016年11月12日 下午5:03:32
// */ */
//@Configuration @Configuration
//@EnableWebMvc @EnableWebMvc
//@ComponentScan(basePackages = {"com.stylefeng.guns.**.controller", "com.stylefeng.guns.common.controller"}) @ComponentScan(basePackages = {"com.stylefeng.guns.**.controller", "com.stylefeng.guns.common.controller"})
//@EnableAspectJAutoProxy @EnableAspectJAutoProxy
//@Import({ControllerAopConfig.class}) @Import({ControllerAopConfig.class})
//public class SpringMvcConfig extends WebMvcConfigurerAdapter { public class SpringMvcConfig extends WebMvcConfigurerAdapter {
//
// // beetl的配置 // beetl的配置
// @Bean(initMethod = "init") @Bean(initMethod = "init")
// public BeetlConfiguration beetlConfiguration() { public BeetlConfiguration beetlConfiguration() {
// BeetlConfiguration beetlConfiguration = new BeetlConfiguration(); BeetlConfiguration beetlConfiguration = new BeetlConfiguration();
// beetlConfiguration.setConfigFileResource(new ClassPathResource("beetl.properties")); beetlConfiguration.setConfigFileResource(new ClassPathResource("beetl.properties"));
// return beetlConfiguration; return beetlConfiguration;
// } }
//
// // beetl的视图解析器 // beetl的视图解析器
// @Bean @Bean
// public BeetlSpringViewResolver beetlViewResolver() { public BeetlSpringViewResolver beetlViewResolver() {
// BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver(); BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver();
// beetlSpringViewResolver.setConfig(beetlConfiguration()); beetlSpringViewResolver.setConfig(beetlConfiguration());
// beetlSpringViewResolver.setContentType("text/html;charset=UTF-8"); beetlSpringViewResolver.setContentType("text/html;charset=UTF-8");
// beetlSpringViewResolver.setOrder(0); beetlSpringViewResolver.setOrder(0);
// return beetlSpringViewResolver; return beetlSpringViewResolver;
// } }
//
// // 配置静态资源的处理,对静态资源的请求转发到servlet容器中默认的servlet上(对静态资源的请求不做处理) // 配置静态资源的处理,对静态资源的请求转发到servlet容器中默认的servlet上(对静态资源的请求不做处理)
// @Override @Override
// public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
// configurer.enable(); configurer.enable();
// } }
//
// // 文件上传用的resolver // 文件上传用的resolver
// @Bean @Bean
// public MultipartResolver multipartResolver() { public MultipartResolver multipartResolver() {
// return new StandardServletMultipartResolver(); return new StandardServletMultipartResolver();
// } }
//
// // 校验器的配置 // 校验器的配置
// @Bean @Bean
// public LocalValidatorFactoryBean validator(ReloadableResourceBundleMessageSource messageSource) { public LocalValidatorFactoryBean validator(ReloadableResourceBundleMessageSource messageSource) {
// LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean(); LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
// localValidatorFactoryBean.setProviderClass(HibernateValidator.class); localValidatorFactoryBean.setProviderClass(HibernateValidator.class);
// localValidatorFactoryBean.setValidationMessageSource(messageSource); localValidatorFactoryBean.setValidationMessageSource(messageSource);
// return localValidatorFactoryBean; return localValidatorFactoryBean;
// } }
//
// // 国际化消息资源文件配置(本系统中主要用于显示/错误消息定制) // 国际化消息资源文件配置(本系统中主要用于显示/错误消息定制)
// @Bean @Bean
// public ReloadableResourceBundleMessageSource messageSource() { public ReloadableResourceBundleMessageSource messageSource() {
// ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
// messageSource.setBasenames("classpath:org/hibernate/validator/ValidationMessages"); messageSource.setBasenames("classpath:org/hibernate/validator/ValidationMessages");
// messageSource.setUseCodeAsDefaultMessage(false); messageSource.setUseCodeAsDefaultMessage(false);
// messageSource.setDefaultEncoding("UTF-8"); messageSource.setDefaultEncoding("UTF-8");
// messageSource.setCacheSeconds(60); messageSource.setCacheSeconds(60);
// return messageSource; return messageSource;
// } }
//
// // 配置全局的验证器实例 // 配置全局的验证器实例
// @Override @Override
// public Validator getValidator() { public Validator getValidator() {
// return this.validator(messageSource()); return this.validator(messageSource());
// } }
//
// // 配置spring mvc的拦截器 // 配置spring mvc的拦截器
// @Override @Override
// public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
//
// } }
//
//
//
// @Bean @Bean
// public ByteArrayHttpMessageConverter byteMsgConverter() { public ByteArrayHttpMessageConverter byteMsgConverter() {
// return new ByteArrayHttpMessageConverter(); return new ByteArrayHttpMessageConverter();
// } }
//
// @Bean @Bean
// public StringHttpMessageConverter stringHttpMessageConverter() { public StringHttpMessageConverter stringHttpMessageConverter() {
// StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter( StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(
// Charset.forName("UTF-8")); Charset.forName("UTF-8"));
// List<MediaType> list = new ArrayList<MediaType>(); List<MediaType> list = new ArrayList<MediaType>();
// list.add(MediaType.TEXT_PLAIN); list.add(MediaType.TEXT_PLAIN);
// stringHttpMessageConverter.setSupportedMediaTypes(list); stringHttpMessageConverter.setSupportedMediaTypes(list);
// return stringHttpMessageConverter; return stringHttpMessageConverter;
// } }
//
//
//
//} }
...@@ -6,6 +6,22 @@ ...@@ -6,6 +6,22 @@
<diskStore path="java.io.tmpdir/ehcache"/> <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" <cache name="CONSTANT"
maxElementsInMemory="50000" 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