简体   繁体   中英

I want to using @WebServlet annotation and @Path annotation to same time in jetty

First, Please forgive me for my clumsy English.

[What I want to do]

I want to know @WebServlet annotation by Servlet 3.0 and @Path annotation by Jersey 2.22.2, It is able to using same time?

[That I want is to help]

  • Can I use two annotations at the same time?
  • If I can use those annotations, is that way how to use?

Thank you.

@Path annotation defines a path to a RESTful Web service so when you have @Path("/SomeService") it will translate into www.yourapp.com/baseRestUrl/SomeService. You can also define it on the methods which provides REST services. Note that baseRestUrl is defined inside web.xml or in class which extends Application class.

On the other hand @WebServlet("/SomePath") states that Servlet will be listening for request on the www.yourapp.com/SomePath, it is basically replacement of servlet-mapping element in web.xml. You can still configure servlets like this, it's up to you whether you prefer XML or annotation configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM