【发布时间】:2021-08-11 16:13:56
【问题描述】:
尝试使用 HttpServlet#doPut 从 PUT 请求中获取参数:
public void doPut(HttpServletRequest request, HttpServletResponse response) {
String name = request.getParameter("name");
// name is null
}
使用 curl 发送请求:
curl -X PUT \
--data "name=batman" \
--header "Content-Type: text/plain" http://localhost:8080/sample.html
使用 doGet 和 GET curl 请求可以正常工作。我错过了什么吗?
【问题讨论】: