Package javax.servlet.annotation
Annotation Type WebServlet
-
@Target(TYPE) @Retention(RUNTIME) @Documented public @interface WebServlet
This annotation is used to declare the configuration of aServlet
.
If the name attribute is not defined, the fully qualified name of the class is used.
At least one URL pattern MUST be declared in either thevalue
orurlPattern
attribute of the annotation, but not both.
Thevalue
attribute is recommended for use when the URL pattern is the only attribute being set, otherwise theurlPattern
attribute should be used.
The class on which this annotation is declared MUST extendHttpServlet
.
E.g.@WebServlet("/path")}
public class TestServlet extends HttpServlet ... {
E.g.@WebServlet(name="TestServlet", urlPatterns={"/path", "/alt"})
public class TestServlet extends HttpServlet ... {- Since:
- Servlet 3.0 (Section 8.1.1)
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description boolean
asyncSupported
String
description
String
displayName
WebInitParam[]
initParams
String
largeIcon
int
loadOnStartup
String
name
String
smallIcon
String[]
urlPatterns
String[]
value
A convenience method, to allow extremely simple annotation of a class.
-
-
-
Element Detail
-
name
String name
- Returns:
- name of the Servlet
- Default:
- ""
-
-
-
value
String[] value
A convenience method, to allow extremely simple annotation of a class.- Returns:
- array of URL patterns
- See Also:
urlPatterns()
- Default:
- {}
-
-
-
urlPatterns
String[] urlPatterns
- Returns:
- array of URL patterns to which this Filter applies
- Default:
- {}
-
-
-
initParams
WebInitParam[] initParams
- Returns:
- array of initialization params for this Servlet
- Default:
- {}
-
-
-
smallIcon
String smallIcon
- Returns:
- small icon for this Servlet, if present
- Default:
- ""
-
-
-
largeIcon
String largeIcon
- Returns:
- large icon for this Servlet, if present
- Default:
- ""
-
-
-
description
String description
- Returns:
- description of this Servlet, if present
- Default:
- ""
-
-
-
displayName
String displayName
- Returns:
- display name of this Servlet, if present
- Default:
- ""
-
-