JSP details-New Features of Servlet3.0

Source: Internet
Author: User

JSP details-New Features of Servlet3.0
Added comments for new features of Servlet3.0

Through annotations, you do not need to configure Servlet or filter in web. xml. Comments added to Servlet3.0 include @ WebServlet, @ WebListener, and @ WebInitParam. The following describes

1. @ WebServlet

@ WebServlet annotation is used to define Servlet components before Servlet class declaration. With this annotation, you do not need to configure the Servlet in web. xml. @ Attributes of WebServlet Annotations:

Attribute name

Type

Description

Name

String

Specify the Servlet name attribute, which is equivalent . If no display is specified, the Servlet value is the fully qualified name of the class.

Value

String []

It is equivalent to the urlPatterns attribute, but the two cannot be used at the same time.

UrlPatterns

String []

Specifies the URL matching mode for a group of servlets. Equivalent Tag

LoadOnStartup

Int

Specify the Servlet loading sequence, which is equivalent Tag

InitParams

WebInitParam []

Specify a set of Servlet initialization parameters, which is equivalent Tag

AsyncSupported

Boolean

Specifies whether the Servlet supports asynchronous operations, which is equivalent

Description

String

Servlet description, equivalent Tag

DiaplayName

Sting

Servlet display name, usually used with tools, is equivalent Tag

2. @ WebFilter

@ WebFilter annotation is used to declare a filter. The annotation will be processed by the container during deployment, and the container will deploy the corresponding class as a filter according to the specific configuration. @ WebFilter attribute list:

Attribute name

Type

Description

FilterName

String

Specify the name attribute of the filter, which is equivalent

Value

Sring []

It is equivalent to the urlPatterns attribute, but the two cannot be used at the same time.

UrlPatterns

String []

Specify the URL matching mode of the filter, which is equivalent Tag

ServletNames

String []

Specify the Servlet to which the filter will apply. It is the value of the name attribute in @ WebServlet or in web. xml. Value

InitParams

WebInitParam []

Specifies the initialization parameters of a set of filters, which is equivalent Tag

AsyncSupported

Boolean

Whether the declared filter supports asynchronous operations is equivalent

Description

String

The description of the filter, which is equivalent

DisplayName

String

The display name of the filter, usually used with tools, is equivalent Tag

DispatcherTypes

DispatcherType

Specify the forwarding mode of the filter, including ASYNC/ERROR/FORWADR/INCLUDE/REQUEST

3. @ WebListener

This annotation is used to declare listeners and act as listener classes for various Web events in a given Web application context. You can use @ WebListener to mark a class that implements ServletContextListener/ServletContextAttributeListener/ServletRequestListner/ServletRequestAttributeListener/HttpSessionListener/HttpSessionAttributeListener. @ WebListener the annotation has a value attribute, which is an optional attribute used to describe listener information. You do not need to configure this annotation in web. xml. Tag

4. @ WebInitParam

This annotation is equivalent And Of Sub-tag. This annotation cannot be used independently. It must be used with @ WebServlet or @ WebFilter. This parameter is used to specify initialization parameters for the Servlet or filter. Attributes contained in the @ WebInitParam annotation:

Attribute name

Type

Optional

Description

Name

String

No

The name of the specified parameter, which is equivalent

Value

String

No

The value of the specified parameter, which is equivalent

Description

String

Yes

The parameter description is equivalent




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.