freemarker.core.Environment.getEffectiveURLEscapingCharset()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(115)

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

Environment.getEffectiveURLEscapingCharset介绍

[英]Returns the name of the charset that should be used for URL encoding. This will be null if the information is not available. The function caches the return value, so it's quick to call it repeatedly.
[中]返回应用于URL编码的字符集的名称。如果信息不可用,则为null。该函数缓存返回值,因此可以快速地重复调用它。

代码示例

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

  1. public String getAsString() throws TemplateModelException {
  2. if (cachedResult == null) {
  3. String cs = env.getEffectiveURLEscapingCharset();
  4. if (cs == null) {
  5. throw new _TemplateModelException(
  6. "To do URL encoding, the framework that encloses FreeMarker must specify the \"",
  7. Configuration.OUTPUT_ENCODING_KEY, "\" setting or the \"",
  8. Configuration.URL_ESCAPING_CHARSET_KEY,
  9. "\" setting, so ask the programmers to set them. Or, as a last chance, you can set the "
  10. + "url_encoding_charset setting in the template, e.g. <#setting ",
  11. Configuration.URL_ESCAPING_CHARSET_KEY,
  12. "='ISO-8859-1'>, or give the charset explicitly to the built-in, e.g. "
  13. + "foo?url('ISO-8859-1').");
  14. }
  15. try {
  16. cachedResult = encodeWithCharset(cs);
  17. } catch (UnsupportedEncodingException e) {
  18. throw new _TemplateModelException(e, "Failed to execute URL encoding.");
  19. }
  20. }
  21. return cachedResult;
  22. }

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

  1. public String getAsString() throws TemplateModelException {
  2. if (cachedResult == null) {
  3. String cs = env.getEffectiveURLEscapingCharset();
  4. if (cs == null) {
  5. throw new _TemplateModelException(
  6. "To do URL encoding, the framework that encloses FreeMarker must specify the \"",
  7. Configuration.OUTPUT_ENCODING_KEY, "\" setting or the \"",
  8. Configuration.URL_ESCAPING_CHARSET_KEY,
  9. "\" setting, so ask the programmers to set them. Or, as a last chance, you can set the "
  10. + "url_encoding_charset setting in the template, e.g. <#setting ",
  11. Configuration.URL_ESCAPING_CHARSET_KEY,
  12. "='ISO-8859-1'>, or give the charset explicitly to the built-in, e.g. "
  13. + "foo?url('ISO-8859-1').");
  14. }
  15. try {
  16. cachedResult = encodeWithCharset(cs);
  17. } catch (UnsupportedEncodingException e) {
  18. throw new _TemplateModelException(e, "Failed to execute URL encoding.");
  19. }
  20. }
  21. return cachedResult;
  22. }

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

  1. public String getAsString() throws TemplateModelException {
  2. if (cachedResult == null) {
  3. String cs = env.getEffectiveURLEscapingCharset();
  4. if (cs == null) {
  5. throw new _TemplateModelException(
  6. "To do URL encoding, the framework that encloses FreeMarker must specify the \"",
  7. Configuration.OUTPUT_ENCODING_KEY, "\" setting or the \"",
  8. Configuration.URL_ESCAPING_CHARSET_KEY,
  9. "\" setting, so ask the programmers to set them. Or, as a last chance, you can set the "
  10. + "url_encoding_charset setting in the template, e.g. <#setting ",
  11. Configuration.URL_ESCAPING_CHARSET_KEY,
  12. "='ISO-8859-1'>, or give the charset explicitly to the built-in, e.g. "
  13. + "foo?url('ISO-8859-1').");
  14. }
  15. try {
  16. cachedResult = encodeWithCharset(cs);
  17. } catch (UnsupportedEncodingException e) {
  18. throw new _TemplateModelException(e, "Failed to execute URL encoding.");
  19. }
  20. }
  21. return cachedResult;
  22. }

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

  1. public String getAsString() throws TemplateModelException {
  2. if (cachedResult == null) {
  3. String cs = env.getEffectiveURLEscapingCharset();
  4. if (cs == null) {
  5. throw new TemplateModelException(
  6. "To do URL encoding, the framework that encloses "
  7. + "FreeMarker must specify the output encoding "
  8. + "or the URL encoding charset, so ask the "
  9. + "programmers to fix it. Or, as a last chance, "
  10. + "you can set the url_encoding_charset setting in "
  11. + "the template, e.g. "
  12. + "<#setting url_escaping_charset='ISO-8859-1'>, or "
  13. + "give the charset explicitly to the buit-in, e.g. "
  14. + "foo?url('ISO-8859-1').");
  15. }
  16. try {
  17. cachedResult = StringUtil.URLEnc(target, cs);
  18. } catch (UnsupportedEncodingException e) {
  19. throw new TemplateModelException(
  20. "Failed to execute URL encoding.", e);
  21. }
  22. }
  23. return cachedResult;
  24. }

相关文章

Environment类方法