• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use @WebServlet like web.xml element  RSS feed

 
Jenkin Zheng
Greenhorn
Posts: 12
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,guys.
I'm a beginner.My English is not good.


the servlet-mapping...



the servlet-mapping...

When I use javax.servlet.annotation.WebServlet. like this:



But one servlet can't duplicate annotation @WebServlet!
How can do it the same like in the web.xml!
Thanks!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37181
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can create a subclass of the servlet with no implementation and define it there. I'd prefer to keep both definitions in the web.xml. It is clearer to show how many instances of the servlet with different parameters there are.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!