4.练习开始:
(1) 【第一个例子:servlet + html + Ajax + Jquery】
首先,创建一个servlet:AjaxServlet
doGet(HttpServletRequest request, HttpServletResponse response)中写:
String param = request.getParameter("car");
System.out.println(param) ;
response.getWriter().print("{ \"name\": \"Violet\", \"occupation\": \"character\" }");
然后, 配置web.xml:
<servlet-mapping>
<servlet-name>ajaxdemo</servlet-name>
<url-pattern><strong><span style="color: rgb(51, 255, 51);">/zyxAjax/ajax.do</span></strong></url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>ajaxW.jsp</welcome-file>
</welcome-file-list>