spring bean 文件中增加

<bean class="cn.zno.smse.common.context.VersionServletContext"></bean>

 

类文件

package cn.zno.smse.common.context;

import java.util.Date;

import javax.servlet.ServletContext;

import org.springframework.web.context.ServletContextAware;

public class VersionServletContext implements ServletContextAware {

    private ServletContext servletContext;
    
    @Override
    public void setServletContext(ServletContext servletContext) {
        this.servletContext=servletContext; 
        getServletContext().setAttribute("resouceVersion", new Date().getTime()); 
    }
    
    public ServletContext getServletContext() {  
        return servletContext;  
    }  
}

 

页面中:

<script type="text/javascript" src="js/common.js?v=${resouceVersion}"></script>

 

转载于:https://www.cnblogs.com/zno2/p/5083473.html

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐