I made my first attempt to create a servlet and in result there is a problem I cannot solve ;(
My entry page, simple hello world, looks this way:
@WebServlet("/")
public class EntryServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
writer.println("Hello World");
writer.close();
}
So my expectation to @WebServlet("/") is that GET / returns Hello World page.
All other requests, ex GET /wrong-url should return 404. Surprisingly, after deploying WAR to Wildfly10, I received "Hello World" for each url I tried.
So @WebServlet("/") behaves as kinda @WebServlet("/*") - is it as it should be or am I doing something wrong?
UPDATE
I found the answer here:
Difference between / and /* in servlet mapping url pattern