アノテーションで web.XML のアノテーション マッピングを提供する方法。私はweb.XMLでやった。次のように、アノテーション マッピングを試してみたいと思います。
<web-app>
<servlet-mapping>
</servlet-mapping>
</web-app>
アノテーションで web.XML のアノテーション マッピングを提供する方法。私はweb.XMLでやった。次のように、アノテーション マッピングを試してみたいと思います。
<web-app>
<servlet-mapping>
</servlet-mapping>
</web-app>
簡単な例は次のとおりです。
@WebServlet(value="/hello")
public class HelloServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
// then write the data of the response
String username = request.getParameter("username");
if (username != null && username.length() > 0) {
out.println("<h2>Hello, " + username + "!</h2>");
}
}
}