什么是 PHP 的 $_POST
的 Java 等价物?在网上搜索了一个小时后,我仍然没有更近的地方。
最佳答案
这是一个简单的例子。我不喜欢 html 或 servlet,但你应该明白。
希望对你有所帮助。
<html>
<body>
<form method="post" action="/myServlet">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" />
</form>
</body>
</html>
现在是 Servlet
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MyServlet extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String userName = request.getParameter("username");
String password = request.getParameter("password");
....
....
}
}
关于java - 使用 Java Servlet 访问 post 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5222/