【问题标题】:How to call java method in xml attribute如何在xml属性中调用java方法
【发布时间】:2020-07-03 20:34:49
【问题描述】:

在下面的 XML 中,我想将 Math:random() 设置为 name 属性的值:

<ehcache name="common.cache" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd">

我尝试了以下方法,但它不起作用:

<ehcache  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:Math="http://www.math.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:math="xalan://java.lang.Math" name="math:random()"
  extension-element-prefixes="math" exclude-result-prefixes="math"  
  xsi:noNamespaceSchemaLocation="ehcache.xsd">

调用Math:random() 方法并为name 属性设置该值的语法是什么?

【问题讨论】:

    标签: java xml spring hibernate ehcache


    【解决方案1】:

    Ehcache 的 XML 配置不支持您尝试实现的目标。 我强烈建议不要在编程 API 中使用这样的命名方案。

    缓存名称用于从缓存管理器中查找缓存以便访问它们。如果配置了磁盘层,它还用于内部识别磁盘缓存文件的潜力。

    简而言之,您的缓存命名方案应该是稳定的而不是随机的。

    【讨论】:

      猜你喜欢
      • 2017-08-13
      • 1970-01-01
      • 2019-03-30
      • 2018-03-03
      • 1970-01-01
      • 2018-06-23
      • 2015-12-03
      • 1970-01-01
      • 2018-03-21
      相关资源
      最近更新 更多