ajax请求servlet简单Demo
index.jsp:
?ajaxServlet.java:
?
package com.ac.servlet;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.*;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class ajaxServlet extends HttpServlet{public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException{String username = request.getParameter("username");String password = request.getParameter("password");String responseText = username+"的密码是"+password+"请牢记!!!!";System.out.println(responseText);PrintWriter out = response.getWriter() ;out.println(responseText);out.close();}}?
web.xml文件配置同上一篇日志