List of usage examples for org.springframework.web.context.support ServletContextResource getFile
@Override public File getFile() throws IOException
From source file:org.cloudfoundry.practical.demo.web.ZippedServletResourceHandler.java
@Override public void afterPropertiesSet() throws Exception { ServletContextResource zipResource = new ServletContextResource(this.servletContext, this.zipFile); UrlResource urlResource = new UrlResource( "jar:" + zipResource.getFile().toURI().toString() + "!/" + this.rootPath + "/"); this.handler = new ResourceHttpRequestHandler(); this.handler.setLocations(Collections.<Resource>singletonList(urlResource)); ((AutowireCapableBeanFactory) this.beanFactory).initializeBean(this.handler, this.beanName + "ResourceHandler"); }
From source file:com.sishuok.es.maintain.icon.web.controller.IconController.java
/** * ? ? ??//from www . j a v a 2 s . c o m * * @param request * @return */ @RequestMapping(value = "/genCssFile") @ResponseBody public String genIconCssFile(HttpServletRequest request) { this.permissionList.assertHasEditPermission(); String uploadFileTemplate = ".%1$s{background:url(%2$s/%3$s);width:%4$spx;height:%5$spx;display:inline-block;vertical-align: middle;%6$s}"; String cssSpriteTemplate = ".%1$s{background:url(%2$s/%3$s) no-repeat -%4$spx -%5$spx;width:%6$spx;height:%7$spx;display:inline-block;vertical-align: middle;%8$s}"; ServletContext sc = request.getServletContext(); String ctx = sc.getContextPath(); List<String> cssList = Lists.newArrayList(); Searchable searchable = Searchable.newSearchable().addSearchParam("type_in", new IconType[] { IconType.upload_file, IconType.css_sprite }); List<Icon> iconList = baseService.findAllWithNoPageNoSort(searchable); for (Icon icon : iconList) { if (icon.getType() == IconType.upload_file) { cssList.add(String.format(uploadFileTemplate, icon.getIdentity(), ctx, icon.getImgSrc(), icon.getWidth(), icon.getHeight(), icon.getStyle())); continue; } if (icon.getType() == IconType.css_sprite) { cssList.add(String.format(cssSpriteTemplate, icon.getIdentity(), ctx, icon.getSpriteSrc(), icon.getLeft(), icon.getTop(), icon.getWidth(), icon.getHeight(), icon.getStyle())); continue; } } try { ServletContextResource resource = new ServletContextResource(sc, iconClassFile); FileUtils.writeLines(resource.getFile(), cssList); } catch (Exception e) { LogUtils.logError("gen icon error", e); return "?" + e.getMessage(); } return "??"; }
From source file:com.daphne.es.maintain.icon.web.controller.IconController.java
/** * ? ? ??//from ww w . j a v a2 s. c o m * * @param request * @return */ @RequestMapping(value = "/genCssFile") @ResponseBody public String genIconCssFile(HttpServletRequest request) { this.permissionList.assertHasEditPermission(); String uploadFileTemplate = ".%1$s{background:url(%2$s/%3$s);width:%4$spx;height:%5$spx;display:inline-block;vertical-align: middle;%6$s}"; String cssSpriteTemplate = ".%1$s{background:url(%2$s/%3$s) no-repeat -%4$spx -%5$spx;width:%6$spx;height:%7$spx;display:inline-block;vertical-align: middle;%8$s}"; ServletContext sc = request.getServletContext(); String ctx = sc.getContextPath(); List<String> cssList = Lists.newArrayList(); Searchable searchable = Searchable.newSearchable().addSearchParam("type_in", new IconType[] { IconType.upload_file, IconType.css_sprite }); List<Icon> iconList = baseService.findAllWithNoPageNoSort(searchable); for (Icon icon : iconList) { if (icon.getType() == IconType.upload_file) { cssList.add(String.format(uploadFileTemplate, icon.getIdentity(), ctx, icon.getImgSrc(), icon.getWidth(), icon.getHeight(), icon.getStyle())); continue; } if (icon.getType() == IconType.css_sprite) { cssList.add(String.format(cssSpriteTemplate, icon.getIdentity(), ctx, icon.getSpriteSrc(), icon.getLeft(), icon.getTop(), icon.getWidth(), icon.getHeight(), icon.getStyle())); continue; } } try { ServletContextResource resource = new ServletContextResource(sc, iconClassFile); FileUtils.writeLines(resource.getFile(), cssList); } catch (Exception e) { LogUtils.logError("gen icon error", e); return "?" + e.getMessage(); } return "??"; }
From source file:com.luna.maintain.icon.web.controller.IconController.java
/** * ? ? ??/*from w ww . ja v a2s . com*/ * * @param request * @return */ @RequestMapping(value = "/genCssFile") @ResponseBody public String genIconCssFile(HttpServletRequest request) { this.permissionList.assertHasEditPermission(); String uploadFileTemplate = ".%1$s{background:url(%2$s/%3$s);width:%4$spx;height:%5$spx;display:inline-block;vertical-align: middle;%6$s}"; String cssSpriteTemplate = ".%1$s{background:url(%2$s/%3$s) no-repeat -%4$spx -%5$spx;width:%6$spx;height:%7$spx;display:inline-block;vertical-align: middle;%8$s}"; ServletContext sc = request.getServletContext(); String ctx = sc.getContextPath(); List<String> cssList = Lists.newArrayList(); Searchable searchable = Searchable.newSearchable().addSearchParam("type_in", new IconType[] { IconType.upload_file, IconType.css_sprite }); List<Icon> iconList = baseService.findAllWithNoPageNoSort(searchable); for (Icon icon : iconList) { if (icon.getType() == IconType.upload_file) { cssList.add(String.format(uploadFileTemplate, icon.getIdentity(), ctx, icon.getImgSrc(), icon.getWidth(), icon.getHeight(), icon.getStyle())); continue; } if (icon.getType() == IconType.css_sprite) { cssList.add(String.format(cssSpriteTemplate, icon.getIdentity(), ctx, icon.getSpriteSrc(), icon.getLeft(), icon.getTop(), icon.getWidth(), icon.getHeight(), icon.getStyle())); continue; } } try { ServletContextResource resource = new ServletContextResource(sc, iconClassFile); FileUtils.writeLines(resource.getFile(), cssList); } catch (Exception e) { log.error("gen icon error", e); return "?" + e.getMessage(); } return "??"; }