java cms静态化_cms-静态化组件

1.要让我们的网站性能更好,那么有的东西是需要做静态化的。做静态化步骤:

1.1在web.xml中配置监听器

1.2.创建一个bean用来实现静态化

web.xml

aa

index.jsp

shiroFilter

org.springframework.web.filter.DelegatingFilterProxy

targetFilterLifecycle

true

shiroFilter

/*

contextConfigLocation

classpath:applicationContext.xml

encodingFilter

org.springframework.web.filter.CharacterEncodingFilter

encoding

UTF-8

encodingFilter

/*

org.springframework.web.context.ContextLoaderListener

com.open1111.service.impl.InitComponet

springMVC

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:spring-mvc.xml

1

springMVC

*.do

springMVC

*.html

2.创建初始化组件类:

package com.open1111.service.impl;

import javax.servlet.ServletContext;

import javax.servlet.ServletContextEvent;

import javax.servlet.ServletContextListener;

import org.springframework.beans.BeansException;

import org.springframework.context.ApplicationContext;

import org.springframework.context.ApplicationContextAware;

import org.springframework.stereotype.Component;

/**

* 初始化组件

* @author user

*

*/

@Component("initComponet")

public class InitComponet implements ApplicationContextAware,ServletContextListener{

private static ApplicationContext applicationContext;

public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {

// TODO Auto-generated method stub

this.applicationContext=applicationContext;

System.out.println(this);

}

/**

* 刷新application缓存方法

* @param application

*/

public void refreshSystem(ServletContext application){

}

public void contextInitialized(ServletContextEvent sce) {

// TODO Auto-generated method stub

ServletContext application=sce.getServletContext();

refreshSystem(application);

}

public void contextDestroyed(ServletContextEvent sce) {

// TODO Auto-generated method stub

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值