【Spring】Spring Framework Reference Documentation中文版38

来源:互联网 发布:阿依莲正品淘宝折扣店 编辑:程序博客网 时间:2024/06/13 22:20

43. spring JSP Tag Library

springJSP标签库

 

43.1 Introduction

介绍

 

One of the view technologies you can use with the Spring Framework is Java Server Pages (JSPs). To help you implement views using Java Server Pages the Spring Framework provides you with some tags for evaluating errors, setting themes and outputting internationalized messages.

你可以使用的其中一个视图技术对于spring框架就是JSP。为了帮助你实现视图使用JSPspring框架提供了一些标签用于解析错误、设置主题和输出国际化信息。

 

Please note that the various tags generated by this form tag library are compliant with the XHTML-1.0-Strict specification and attendant DTD.

请注意不同的标签来自于标签库都符合XHTML-1.0-Strict规范和标准的DTD

 

This appendix describes the spring.tld tag library.

这个附录描述了spring.tld标签库。

 

    Section 43.2, The argument tag

    Section 43.3, The bind tag

    Section 43.4, The escapeBody tag

    Section 43.6, The hasBindErrors tag

    Section 43.7, The htmlEscape tag

    Section 43.8, The message tag

    Section 43.9, The nestedPath tag

    Section 43.10, The param tag

    Section 43.11, The theme tag

    Section 43.12, The transform tag

    Section 43.13, The url tag

    Section 43.5, The eval tag

 

43.2 The argument tag

 

Argument tag based on the JSTL fmt:param tag. The purpose is to support arguments inside the message and theme tags.

Argument标签基于JSTLfmt:param标签。目的是提供消息和主题标签中的参数支持。

 

Table 43.1. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

运行时解析

Description

描述

value

FALSE

TRUE

The value of the argument.

 

43.3 The bind tag

 

Provides BindStatus object for the given bind path. The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml).

提供了BIndStatusobject用于给定的绑定路径。html的逃逸标志参与页面范围或应用范围的设置(例如,通过HtmlEscapeTag"defaultHtmlEscape"的上下文参数在web.xml中)

 

Table 43.2. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

运行时解析

Description

描述

htmlEscape

FALSE

TRUE

Set HTML escaping for this tag, as boolean value. Overrides the default HTML escaping setting for the current page.

设置这个标签的HTML逃逸,作为布尔值。覆盖默认的HTML逃逸设置对于当前的页面。

ignoreNestedPath

FALSE

TRUE

Set whether to ignore a nested path, if any. Default is to not ignore.

设置是否忽略内置的路径。默认是不忽略。

path

TRUE

TRUE

The path to the bean or bean property to bind status information for. For instance account.name, company.address.zipCode or just employee. The status object will exported to the page scope, specifically for this bean or bean property

对于beanbean属性的路径,绑定状态信息用于实例accountnamecompanyaddresszipCOde或只是employee。状态object将导出给页面范围,指定这个beanbean属性。

 

43.4 The escapeBody tag

 

Escapes its enclosed body content, applying HTML escaping and/or JavaScript escaping. The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml).

escapes本身处理内容体,应用HTML的逃逸和JavaScript的逃逸。HTML的逃逸标志参与页面范围或应用范围的设置(例如,通过HtmlEscapeTag"defaultHtmlEscape"的上下文参数在web.xml中)。

 

Table 43.3. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

运行时解析

Description

描述

htmlEscape

FALSE

TRUE

Set HTML escaping for this tag, as boolean value. Overrides the default HTML escaping setting for the current page.

设置HTML的逃逸对于这个标签作为布尔手续ing。覆盖默认的HTML逃逸设置对于这个属性。

javaScriptEscape

FALSE

TRUE

Set JavaScript escaping for this tag, as boolean value. Default is false.

设置JavaScript的逃逸对于这个属性作为布尔值。默认是false

 

43.5 The eval tag

 

Evaluates a Spring expression (SpEL) and either prints the result or assigns it to a variable.

处理spring的表达式(SpEL)和输出结果或指定变量。

 

Table 43.4. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

运行时解析

Description

描述

expression

TRUE

TRUE

The expression to evaluate.

需要解析的表达式

htmlEscape

FALSE

TRUE

Set HTML escaping for this tag, as a boolean value. Overrides the default HTML escaping setting for the current page.

设置HTML逃逸对于这个标签,作为布尔值。覆盖默认的HTML逃逸设置对于当前的页面。

javaScriptEscape

FALSE

TRUE

Set JavaScript escaping for this tag, as a boolean value. Default is false.

设置JavaScript的逃逸对于这个标签作为布尔值。默认是false

scope

FALSE

TRUE

The scope for the var. 'application', 'session', 'request' and 'page' scopes are supported. Defaults to page scope. This attribute has no effect unless the var attribute is also defined.

变量的范围,支持应用、会话、请求和页面范围。默认是页面范围。这个属性没有影响除非var属性也被定义了。

var

FALSE

TRUE

The name of the variable to export the evaluation result to. If not specified the evaluation result is converted to a String and written as output.

变量名暴露给解析结果。没有指定解析结果转化为字符串和作为输出。

 

43.6 The hasBindErrors tag

 

Provides Errors instance in case of bind errors. The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml).

提供了Errors实例用于绑定错误。HTML逃逸标志参与页面范围或应用范围的设置(例如,通过HtmlEscapeTagdefaultHtmlEscape的上下文属性在web.xml中)。

 

Table 43.5. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

运行时解析

Description

描述

htmlEscape

FALSE

TRUE

Set HTML escaping for this tag, as boolean value. Overrides the default HTML escaping setting for the current page.

设置HTML逃逸对于这个标签作为布尔值。覆盖默认的HTML逃逸设置对于当前页面。

name

TRUE

TRUE

The name of the bean in the request, that needs to be inspected for errors. If errors are available for this bean, they will be bound under the 'errors' key.

请求中bean的名字,需要指定错误。如果错误对个这个bean可用,将被绑定到error的关键字上。

 

43.7 The htmlEscape tag

 

Sets default HTML escape value for the current page. Overrides a "defaultHtmlEscape" context-param in web.xml, if any.

参见默认的HTML逃逸值用于当前页面。覆盖defaultHtmlEscape的上下文属性在web.xml,如果any

 

Table 43.6. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

运行时解析

Description

描述

defaultHtmlEscape

TRUE

TRUE

Set the default value for HTML escaping, to be put into the current PageContext.

设置HTML逃逸的默认值,将被放置到PageContext中。

 

43.8 The message tag

 

Retrieves the message with the given code, or text if code isnt resolvable. The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml).

对于给定的代码接收消息,或记录文本如果代码不能被解析。HTML逃逸标志参与页面范围或应用范围的设置(例如,通过HtmlEscapeTagdefaultHtmlEscape的上下文参数在web.xml中)

 

Table 43.7. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

运行时解析

Description

描述

arguments

FALSE

TRUE

Set optional message arguments for this tag, as a (comma-)delimited String (each String argument can contain JSP EL), an Object array (used as argument array), or a single Object (used as single argument).

设置可选的信息参数用于这个标签,作为逗号分隔字符串(每个字符串参数可以包含一个JSPEL),一个object属性(作为参数数组)或一个单一的object(使用作为单一的参数)

argumentSeparator

FALSE

TRUE

The separator character to be used for splitting the arguments string value; defaults to a 'comma' (',').

分隔符将被用于分隔参数的字符串值,默认是逗号。

code

FALSE

TRUE

The code (key) to use when looking up the message. If code is not provided, the text attribute will be used.

使用的代码来查找消息。如果没有提供则使用text属性的内容。

htmlEscape

FALSE

TRUE

Set HTML escaping for this tag, as boolean value. Overrides the default HTML escaping setting for the current page.

设置HTML逃逸对于这个标签作为布尔值。覆盖默认的HTML逃逸设置对于当前的页面。

javaScriptEscape

FALSE

TRUE

Set JavaScript escaping for this tag, as boolean value. Default is false.

设置JavaScript的逃逸对于这个标签作为布尔值。默认是false

message

FALSE

TRUE

A MessageSourceResolvable argument (direct or through JSP EL). Fits nicely when used in conjunction with Springs own validation error classes which all implement the MessageSourceResolvable interface. For example, this allows you to iterate over all of the errors in a form, passing each error (using a runtime expression) as the value of this 'message' attribute, thus effecting the easy display of such error messages.

MessageSourceResolvable参数(直接或通过JSPEL)。符合使用spring自身的验证机制对于所有实现MessageSourceResolvable的接口。例如他允许你遍历所有表单中的错误,传递每个错误(使用运行时表达式)作为这个message属性的值,影响每个显示的错误消息。

scope

FALSE

TRUE

The scope to use when exporting the result to a variable. This attribute is only used when var is also set. Possible values are page, request, session and application.

当暴露结果给变量时使用的范围。这个属性只用于var被设置的时候。取值可能是pagerequestsessionapplication

text

FALSE

TRUE

Default text to output when a message for the given code could not be found. If both text and code are not set, the tag will output null.

对于没有找到给定的code输出的文本消息。如果testcode都没有设置则输出null

var

FALSE

TRUE

The string to use when binding the result to the page, request, session or application scope. If not specified, the result gets outputted to the writer (i.e. typically directly to the JSP).

当绑定pagerequestsessionapplication时使用的字符串。如果没有指定的结果将输出给writer。(例如典型是给JSP)。

 

43.9 The nestedPath tag

 

Sets a nested path to be used by the bind tags path.

设置使用的内置路径来绑定标签的路径

 

Table 43.8. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

运行时解析

Description

描述

path

TRUE

TRUE

Set the path that this tag should apply. E.g. 'customer' to allow bind paths like 'address.street' rather than 'customer.address.street'.

设置这个标签应当应用的路径。例如customer允许绑定路径类似于address.street而不是customer.address.street

 

43.10 The param tag

 

Parameter tag based on the JSTL c:param tag. The sole purpose is to support params inside the url tag.

参数标签基于JSTL c:param标签。目的是支持内置于url标签中的参数。

 

Table 43.9. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

运行时解析

Description

描述

name

TRUE

TRUE

The name of the parameter.

参数的名字

value

FALSE

TRUE

The value of the parameter.

参数的值

 

43.11 The theme tag

 

Retrieves the theme message with the given code, or text if code isnt resolvable. The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml).

对于给定的代码接收主题消息或文本如果代码没有被解析的话。HTML逃逸标志参与页面范围或应用范围的设置(例如,通过HtmlEscapeTagdefaultHtmlEscape的上下文参数在web.xml中)

 

Table 43.10. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

Description

描述

arguments

FALSE

TRUE

Set optional message arguments for this tag, as a (comma-)delimited String (each String argument can contain JSP EL), an Object array (used as argument array), or a single Object (used as single argument).

设置可选的消息参数对于这个标签,作为逗号分隔的字符串(每个字符串可以包含JSPEL),一个object属性(使用作为参数数组)或单一的object(使用作为单一的参数)

argumentSeparator

FALSE

TRUE

The separator character to be used for splitting the arguments string value; defaults to a 'comma' (',').

使用的分隔的字符串用于分隔字符串参数值;默认是逗号。

code

FALSE

TRUE

The code (key) to use when looking up the message. If code is not provided, the text attribute will be used.

查找消息使用的关键字。如果没有提供代码,将使用text属性。

htmlEscape

FALSE

TRUE

Set HTML escaping for this tag, as boolean value. Overrides the default HTML escaping setting for the current page.

设置HTML逃逸用于这个标签,作为布尔值。覆盖默认的HTML逃逸设置用于当前页面。

javaScriptEscape

FALSE

TRUE

Set JavaScript escaping for this tag, as boolean value. Default is false.

设置JavaScript的逃逸用于这个标签,作为布尔值。默认是false

message

FALSE

TRUE

A MessageSourceResolvable argument (direct or through JSP EL).

一个MessageSourceResolvable参数(直接或通过JSPEL

scope

FALSE

TRUE

The scope to use when exporting the result to a variable. This attribute is only used when var is also set. Possible values are page, request, session and application.

暴露给变量的使用的范围。这个属性只会用于设置了var的前提下。可能的取值范围是pagerequestsessionapplication

text

FALSE

TRUE

Default text to output when a message for the given code could not be found. If both text and code are not set, the tag will output null.

默认的输出文本用于给定代码没有找到的情况洗。如果textcode都没有设置则默认输出null

var

FALSE

TRUE

The string to use when binding the result to the page, request, session or application scope. If not specified, the result gets outputted to the writer (i.e. typically directly to the JSP).

绑定结果的使用的字符串对于pagerequestsessionapplication。如果没有指定 ,结果输出给writer(例如,通常就是直接给JSP)。

 

43.12 The transform tag

 

Provides transformation of variables to Strings, using an appropriate custom PropertyEditor from BindTag (can only be used inside BindTag). The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a 'defaultHtmlEscape' context-param in web.xml).

提供转换变量为字符串,使用适当的自定的PropertyEditor来自BindTage(只能用于BindTag之中)。HTML逃逸标志参与页面范围或应用范围的设置(例如,通过HtmlEscapeTagdefaultHtmlEscape上下文参数在web.xml中)。

 

Table 43.11. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

Description

描述

htmlEscape

FALSE

TRUE

Set HTML escaping for this tag, as boolean value. Overrides the default HTML escaping setting for the current page.

设置HTML逃逸用于这个标签,作为布尔值。覆盖默认的HTML逃逸设置对于当前页面。

scope

FALSE

TRUE

The scope to use when exported the result to a variable. This attribute is only used when var is also set. Possible values are page, request, session and application.

暴露给变量的使用的范围。这个属性只会用于设置了var的前提下。可能的取值范围是pagerequestsessionapplication

value

TRUE

TRUE

The value to transform. This is the actual object you want to have transformed (for instance a Date). Using the PropertyEditor that is currently in use by the 'spring:bind' tag.

转换的值。这个是实际的你希望转换的object(例如一个Date)。使用PropertyEditor使用实际被使用于spring:bind标签。

var

FALSE

TRUE

The string to use when binding the result to the page, request, session or application scope. If not specified, the result gets outputted to the writer (i.e. typically directly to the JSP).

绑定结果的使用的字符串对于pagerequestsessionapplication。如果没有指定 ,结果输出给writer(例如,通常就是直接给JSP)。

 

43.13 The url tag

 

Creates URLs with support for URI template variables, HTML/XML escaping, and Javascript escaping. Modeled after the JSTL c:url tag with backwards compatibility in mind.

创建URL使用给定的URI模板变量,HTMLXML逃逸,和JavaScript逃逸。在JSTL c:url标签后模仿向后兼容。

 

Table 43.12. Attributes

Attribute

属性

Required?

是否必须

Runtime Expression?

Description

描述

value

TRUE

TRUE

The URL to build. This value can include template {placeholders} that are replaced with the URL encoded value of the named parameter. Parameters must be defined using the param tag inside the body of this tag.

构建的URL。这个值可以包括模板{占位符}来替代URL编码值对于命名的参数。参数必须定义使用参数标记在这个标记的内部。

context

FALSE

TRUE

Specifies a remote application context path. The default is the current application context path.

指定远程应用上下文路径。默认是当前应用上下文路径。

var

FALSE

TRUE

The name of the variable to export the URL value to. If not specified the URL is written as output.

变量的值暴露了URL值。如果没有指定URL将作为输出。

scope

FALSE

TRUE

The scope for the var. 'application', 'session', 'request' and 'page' scopes are supported. Defaults to page scope. This attribute has no effect unless the var attribute is also defined.

变量的范围,支持applicationsessionrequestpage范围。默认是page范围。这个属性在指定var属性时才有意义。

htmlEscape

FALSE

TRUE

Set HTML escaping for this tag, as a boolean value. Overrides the default HTML escaping setting for the current page.

设置HTML逃逸用于这个标签,作为布尔值。覆盖了默认的HTML逃逸对于当前页面。

javaScriptEscape

FALSE

TRUE

Set JavaScript escaping for this tag, as a boolean value. Default is false.

设置JavaScript逃逸对于这个标签,作为布尔值。默认是false

 

阅读全文
0 0
原创粉丝点击