首页 > 编程知识 正文

web项目常见问题及解决方案,项目存在的问题及解决方法

时间:2023-05-04 06:35:59 阅读:240833 作者:4074

java web项目发版js或css缓存问题解决方案给引入的js或css文件加版本号<%     // 加载资源文件
    PropertiesResourceFileUtils prfu = new PropertiesResourceFileUtils("version.properties"); %><script type="text/javascript" src="<%=basePath%>script/common/common.js?version=<%=prfu.getValue("version") %>"></script><link rel="stylesheet" type="text/css" rel="external nofollow" href="<%=basePath%>css/epoch.css?version=<%=prfu.getValue("version") %>">version.properties文件:#版本号
version=20161125.02public class PropertiesResourceFileUtils {
 /**  private Properties properties = new Properties();
 
 /**  public PropertiesResourceFileUtils(String propertiesPath) {
        try {
            InputStream in = PropertiesResourceFileUtils.class.getClassLoader().getResourceAsStream(propertiesPath);
            if(in != null) {
                properties.load(in);
            }
        }
        catch (IOException e) {
            e.printStackTrace();
        } 
 }    /**     public String getValue(String key){
        String value = properties.getProperty(key);
        if(StringUtils.isNotBlank(value))
            try {
                value = new String(value.getBytes("ISO-8859-1"), "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        return value;
    }
}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。