freemarker.cache.WebappTemplateLoader.getURLConnectionUsesCaches()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中freemarker.cache.WebappTemplateLoader.getURLConnectionUsesCaches()方法的一些代码示例,展示了WebappTemplateLoader.getURLConnectionUsesCaches()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebappTemplateLoader.getURLConnectionUsesCaches()方法的具体详情如下:
包路径:freemarker.cache.WebappTemplateLoader
类名称:WebappTemplateLoader
方法名:getURLConnectionUsesCaches

WebappTemplateLoader.getURLConnectionUsesCaches介绍

[英]Getter pair of #setURLConnectionUsesCaches(Boolean).
[中]#SetUrlConnectionUseCaches的Getter对(布尔值)。

代码示例

代码示例来源:origin: org.freemarker/freemarker

  1. public Object findTemplateSource(String name) throws IOException {
  2. String fullPath = subdirPath + name;
  3. if (attemptFileAccess) {
  4. // First try to open as plain file (to bypass servlet container resource caches).
  5. try {
  6. String realPath = servletContext.getRealPath(fullPath);
  7. if (realPath != null) {
  8. File file = new File(realPath);
  9. if (file.canRead() && file.isFile()) {
  10. return file;
  11. }
  12. }
  13. } catch (SecurityException e) {
  14. ;// ignore
  15. }
  16. }
  17. // If it fails, try to open it with servletContext.getResource.
  18. URL url = null;
  19. try {
  20. url = servletContext.getResource(fullPath);
  21. } catch (MalformedURLException e) {
  22. LOG.warn("Could not retrieve resource " + StringUtil.jQuoteNoXSS(fullPath),
  23. e);
  24. return null;
  25. }
  26. return url == null ? null : new URLTemplateSource(url, getURLConnectionUsesCaches());
  27. }

代码示例来源:origin: org.freemarker/freemarker-gae

  1. public Object findTemplateSource(String name) throws IOException {
  2. String fullPath = subdirPath + name;
  3. if (attemptFileAccess) {
  4. // First try to open as plain file (to bypass servlet container resource caches).
  5. try {
  6. String realPath = servletContext.getRealPath(fullPath);
  7. if (realPath != null) {
  8. File file = new File(realPath);
  9. if (file.canRead() && file.isFile()) {
  10. return file;
  11. }
  12. }
  13. } catch (SecurityException e) {
  14. ;// ignore
  15. }
  16. }
  17. // If it fails, try to open it with servletContext.getResource.
  18. URL url = null;
  19. try {
  20. url = servletContext.getResource(fullPath);
  21. } catch (MalformedURLException e) {
  22. LOG.warn("Could not retrieve resource " + StringUtil.jQuoteNoXSS(fullPath),
  23. e);
  24. return null;
  25. }
  26. return url == null ? null : new URLTemplateSource(url, getURLConnectionUsesCaches());
  27. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

  1. public Object findTemplateSource(String name) throws IOException {
  2. String fullPath = subdirPath + name;
  3. if (attemptFileAccess) {
  4. // First try to open as plain file (to bypass servlet container resource caches).
  5. try {
  6. String realPath = servletContext.getRealPath(fullPath);
  7. if (realPath != null) {
  8. File file = new File(realPath);
  9. if (file.canRead() && file.isFile()) {
  10. return file;
  11. }
  12. }
  13. } catch (SecurityException e) {
  14. ;// ignore
  15. }
  16. }
  17. // If it fails, try to open it with servletContext.getResource.
  18. URL url = null;
  19. try {
  20. url = servletContext.getResource(fullPath);
  21. } catch (MalformedURLException e) {
  22. LOG.warn("Could not retrieve resource " + StringUtil.jQuoteNoXSS(fullPath),
  23. e);
  24. return null;
  25. }
  26. return url == null ? null : new URLTemplateSource(url, getURLConnectionUsesCaches());
  27. }

相关文章