Java获取Webapp下的css、js、image资源
2015-09-11 11:27
232 查看
在使用easyui时,有个需求,想要弹出一个框,可以选择图标,效果如下:
,实现的时候需要从css中加载以上的图标样式。其中,css样式如下:
代码如下:
最后,页面上获取List,动态组装成table,在一个弹出的window里显示,即可。
,实现的时候需要从css中加载以上的图标样式。其中,css样式如下:
.icon-loginpassword{background:url('IconsExtension/icon-password.png') no-repeat center center;} .icon-loginuser{background:url('IconsExtension/icon-user.png') no-repeat center center;} .icon-01{background:url('IconsExtension/01.png') no-repeat center center;} .icon-1012333{background:url('IconsExtension/1012333.png') no-repeat center center;} .icon-2012080111634{background:url('IconsExtension/2012080111634.png') no-repeat center center;} .icon-2012080404218{background:url('IconsExtension/2012080404218.png') no-repeat center center;} .icon-2012080404391{background:url('IconsExtension/2012080404391.png') no-repeat center center;} .icon-2012080407553{background:url('IconsExtension/2012080407553.png') no-repeat center center;} .icon-2012080412111{background:url('IconsExtension/2012080412111.png') no-repeat center center;} .icon-201208041220{background:url('IconsExtension/201208041220.png') no-repeat center center;} .icon-2012080412263{background:url('IconsExtension/2012080412263.png') no-repeat center center;} .icon-2012080412301{background:url('IconsExtension/2012080412301.png') no-repeat center center;} .icon-2012080412486{background:url('IconsExtension/2012080412486.png') no-repeat center center;} .icon-2012080412511{background:url('IconsExtension/2012080412511.png') no-repeat center center;} .icon-2012080412901{background:url('IconsExtension/2012080412901.png') no-repeat center center;} .icon-2012081511202{background:url('IconsExtension/2012081511202.png') no-repeat center center;} .icon-2012081511767{background:url('IconsExtension/2012081511767.png') no-repeat center center;} .icon-2012081511913{background:url('IconsExtension/2012081511913.png') no-repeat center center;} .icon-2012092109942{background:url('IconsExtension/2012092109942.png') no-repeat center center;}
代码如下:
String CSS_PATH = "/css/IconExtension.css"; String cssPath = request.getSession().getServletContext().getRealPath(CSS_PATH); List<Icon> icons = new ArrayList<Icon>(); try { BufferedReader reader = new BufferedReader(new FileReader(new File(cssPath))); String str = null; while ( (str = reader.readLine()) != null) { int dotInd = str.indexOf("."); int kInd = str.indexOf("{"); String className = str.substring(dotInd+1,kInd); String img = "/css/" + str.substring(str.indexOf("'")+1, str.lastIndexOf("'")); icons.add(new Icon(className,img)); } } catch (Exception e) { e.printStackTrace(); } model.addAttribute("icons", icons);
最后,页面上获取List,动态组装成table,在一个弹出的window里显示,即可。
相关文章推荐
- webappbuilder改变leftpanel的大小
- Eclipse+Maven创建webapp项目
- 采用Jetty搭建简单的WebApplicationServer
- webapp开发要点记录
- WEBAPP介绍及其iOS Web开发技巧总结
- web.xml中webAppRootKey
- 关于使用zepto框架中的tap click穿透事件 webapp开发
- HTML5八大特性助力移动WebApp开发
- webapp开发框架推荐以及优缺点分析【webAPP干货】
- Intellij里新建maven的webapp项目
- webkit webApp 开发技术要点总结[转]
- 移动webapp前端开发小结
- Spring MVC学习------------WebApplicationContext
- SpringMVC加载WebApplicationContext源码分析
- [转] Log4j 配置 的webAppRootKey参数问题
- [转]web.xml中webAppRootKey
- Cordova webapp实战开发:(7)如何通过简单的方法做到,不重新发布APP来修复bug、增加功能、或者躲开苹果的一些严格审核?
- Eclipse+Maven创建webapp项目<二>
- Eclipse+Maven创建webapp项目<一>
- 使用m2Eclipse 通过 maven 自动部署webapp到weblogic 12c