An annotation mapping web.XML annotations provided. I have done with the web. XML I want to try with annotations mapping I like:
& lt; Web-app & gt; & Lt; Servlet-mapping & gt; & Lt; / Servlet-mapping & gt; & Lt; / Web application & gt;
A simple example:
@WebServlet (value = "/ hello") public class extends HelloServlet HttpServlet {@ override public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {PrintWriter out = response.getWriter (); // then write the data of the response to the string user name = request.getParameter ("username"); If (username! = Null & amp; username. Length () & gt; 0) {out.println ( "& lt; h2 & gt; hello," + username + "! & Lt; / h2 & gt ; "); }}}
No comments:
Post a Comment