一、属性文件:version.properties -》内容:version=201608 

二、java代码

public class configVersion implements ServletContextAware {

    private ServletContext servletContext;

    @Override
    public void setServletContext(ServletContext servletContext) {
        this.servletContext = servletContext;
    }

    @Value("${version}")  //取属性文件值SpringMVC功能
    private String version;

    public void init() {
// String version = new Date() + Math.random(); //第二种方法:可以直接给一个(日期+随机数) servletContext.setAttribute(
"version", version); } }

 

三、 applicationContext.xml配置

<bean class="com.zhihui.base.configVersion " init-method="init"></bean>

 

四、html引用外部资源

<script src="/js/shopping.js?v=${version}"></script>

servletContext.setAttribute("version", version);

相关文章:

  • 2021-07-31
  • 2021-06-04
  • 2021-06-28
  • 2021-11-23
  • 2022-12-23
  • 2021-12-24
  • 2021-12-30
  • 2022-12-23
猜你喜欢
  • 2021-09-20
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案