使用$.post方式来实现页面的局部刷新功能

html>
lang="en">

charset="UTF-8">
Title<span style="color:#e8bf6a;">




type="button" value="发送异步请求" οnclick="fun();">
type="text">



package cn.hopetesting.com;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
* @author newcityman
* @date 2019/9/16 - 21:53
*/
@WebServlet("/ajaxServlet")
public class AjaxServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String username = request.getParameter("username");
/* try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}*/
System.out.println(username);
response.getWriter().write("hello,"+username+".");
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
}
 

转载于:https://www.cnblogs.com/newcityboy/p/11530977.html

你可能感兴趣的:(使用$.post方式来实现页面的局部刷新功能)