什么是和用于?

时间:2021-11-14 08:36:43

I was working on custom tag libraries and I was confused how the <required> and <rtexprvalue> tags are used in the TLD file to define a custom tag attribute.

我正在研究自定义标记库,我很困惑如何在TLD文件中使用 标记来定义自定义标记属性。

  1. What are these tags?
  2. 这些标签是什么?
  3. What should we write in-between them?
  4. 我们应该在他们之间写什么?
  5. What behavior do we get after writing these tags?
  6. 写这些标签后我们会得到什么样的行为?

2 个解决方案

#1


66  

required quite simply implies what it says. The attribute is required or mandatory.

要求非常简单地暗示它所说的内容。该属性是必需的或必需的。

rtexprvalue means Runtime Expression Value. It means the attribute can support scriptlet values.

rtexprvalue表示运行时表达式值。这意味着该属性可以支持scriptlet值。

elexprvalue means it can support EL (expression language) values.

elexprvalue意味着它可以支持EL(表达式语言)值。

So, if you have requiredattr defined as both required=true and rtexprvalue=true and elattribute is defined as elexprvalue=true, you can write as follows:

因此,如果您将requiredattr定义为required = true和rtexprvalue = true且elattribute定义为elexprvalue = true,则可以按如下方式编写:

<myprefix:mytag requiredattr="<%=baz.getId()%>" elattribute="${foo.bar}"/>

#2


7  

The <rtexprvalue> element defined in a TLD captures the dynamic behavior of an attribute. The value can be either true or false. A false value in the dynamic column means that only a static string value can be specified for the attribute. A true value means that a request-time attribute value can be specified. As defined in the JSP specification, a “request-time attribute value” can be either a Java expression, an EL expression, or a value set by a <jsp:attribute>.

TLD中定义的 元素捕获属性的动态行为。值可以是true或false。动态列中的false值表示只能为属性指定静态字符串值。 true值表示可以指定请求时属性值。如JSP规范中所定义,“请求时属性值”可以是Java表达式,EL表达式或由 设置的值。 :attribute>

The <required> element defines if the nesting attribute is required or optional. If not present then the default is "false", i.e the attribute is optional.

元素定义嵌套属性是必需的还是可选的。如果不存在则默认为“false”,即该属性是可选的。

#1


66  

required quite simply implies what it says. The attribute is required or mandatory.

要求非常简单地暗示它所说的内容。该属性是必需的或必需的。

rtexprvalue means Runtime Expression Value. It means the attribute can support scriptlet values.

rtexprvalue表示运行时表达式值。这意味着该属性可以支持scriptlet值。

elexprvalue means it can support EL (expression language) values.

elexprvalue意味着它可以支持EL(表达式语言)值。

So, if you have requiredattr defined as both required=true and rtexprvalue=true and elattribute is defined as elexprvalue=true, you can write as follows:

因此,如果您将requiredattr定义为required = true和rtexprvalue = true且elattribute定义为elexprvalue = true,则可以按如下方式编写:

<myprefix:mytag requiredattr="<%=baz.getId()%>" elattribute="${foo.bar}"/>

#2


7  

The <rtexprvalue> element defined in a TLD captures the dynamic behavior of an attribute. The value can be either true or false. A false value in the dynamic column means that only a static string value can be specified for the attribute. A true value means that a request-time attribute value can be specified. As defined in the JSP specification, a “request-time attribute value” can be either a Java expression, an EL expression, or a value set by a <jsp:attribute>.

TLD中定义的 元素捕获属性的动态行为。值可以是true或false。动态列中的false值表示只能为属性指定静态字符串值。 true值表示可以指定请求时属性值。如JSP规范中所定义,“请求时属性值”可以是Java表达式,EL表达式或由 设置的值。 :attribute>

The <required> element defines if the nesting attribute is required or optional. If not present then the default is "false", i.e the attribute is optional.

元素定义嵌套属性是必需的还是可选的。如果不存在则默认为“false”,即该属性是可选的。