Difference between javax.servlet-api.jar vs servlet-api.jar

后端 未结 5 495
囚心锁ツ
囚心锁ツ 2021-01-01 14:05

In my maven repository under groupId javax.servlet i have these two separate artifacts for servlets. I am confused which one should i use to build a simple serv

5条回答
  •  有刺的猬
    2021-01-01 14:26

    javax.servlet-api version 3.0.1 has annotation folder which contains different annotation classes where servlet-api version 2.5 or below (i.e version 2.4) does not contain annotation.

    Annotation represents the metadata. If you use annotation, deployment descriptor i.e. web.xml is not required. For example if you use annotation like @WebServlet("/hello") in your servlet file then you don't need to mention servlet mapping in web.xml file.

    Some of useful Annotations are:

    @HandlesTypes
    @HttpConstraint 
    @HttpMethodConstraint
    @MultipartConfig
    @ServletSecurity
    @WebFilter
    @WebInitParam
    @WebListener
    @WebServlet
    

提交回复
热议问题