Reputation: 3243
Im tryign to create a url like the following, is this even allowed, using annotation @WebServlet ?
urlPatterns = { "/name/*/title" }
I can the following to work
urlPatterns = { "/name/*" }
I am completely new to this, i want to do something like rest type thing, i know how to do this using spring mvc. but here im limited to webservlets
Upvotes: 2
Views: 6158
Reputation: 5668
Yes the urlPattern urlPatterns = { "/name/*/title" }
is completely legal and should work fine.
You can declare it like
@WebServlet(
urlPatterns={"/one/*/abc"} ,
name="ServletOne",
initParams={
@WebInitParam(name = "name", value = "abc")
}
)
How-ever, keep in mind that here *
is not treated as a wild-card. Servlets do not support wild-cards patterns in the middle of the mapping. So /name/*/title
does not mean /name/<anything>/title
.
Edit
If you want to hit a URL like /name/*/title
where *
can be anything, then the URL /one/*
should serve the purpose just fine.
Upvotes: 4