Which of following annotations can be used in a servlet class?
(i) @javax.annotation.Resource
(ii) @javax.annotation.PreDestroy
(iii) @javax.annotation.security.RunAs
(iv) @javax.annotation.security.RolesAllowed
(v) @javax.servlet.annotation.WebServlet
A. (v) only
B. (i) and (v)
C. (i), (ii), (iii) and (v)
D. (i), (ii), (iv) and (v)
E. (i), (ii), (iii), (iv) and (v)
Correct Answer: B
Explanation/Reference:
* (i) The javax.annotation.Resource annotation is used to declare a reference to a resource. @Resource can
decorate a class, a field, or a method.
* (v) javax.servlet.annotation
Annotation Type WebServlet
Annotation used to declare a servlet.
This annotation is processed by the container at deployment time, and the corresponding servlet made
available at the specified URL patterns.
Incorrect:
* Not (II) : javax.annotation.PreDestroy
Target: Method
沒有留言:
張貼留言