解决html图片动态刷新以及Apache Shiro拦截图片显示问题

一丶实现页面图片通过后台进行动态修改

(1)后台传递图片路径与随机数

        //读取最新首页图片
        List<Attach> attachs = Md.selectList("attach.getloginimg", null,
				Attach.class);
        //避免网页调用缓存数据
        String random=new Date().getTime()%100000+""+new Random().nextInt(100000);
        mm.put("random",random);
        mm.put("attachs",attachs);

(2)页面获取并展示图片

	<img src="${ctxPath}${attachs[0].url}?random=${random}">

二丶对于项目框架涉及Apache Shiro时,要注意shiro是否放开对于图片路径的限制

	<property name="filterChainDefinitions">
			<value>
				/upload/**=anon
			</value>
	</property>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章