java怎么获取httppost方式传过来的数据?
用servlet来得到。通过request对象的getParameter()方法来获取。
前端的jsp页面:
<body>
<form action="/requestDemo" method="post">
<input type="text" placeholder="请输入用户名" name="username"><br> </form>
</body>
后台的java代码:
@WebServlet("/requestDemo")
public class RequestDemo extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//post 获取请求参数
//根据参数名称获取参数值
String username = request.getParameter("username");
System.out.println("post");
System.out.println(username);
}
java用HttpClients请求url返回状态码是503怎么处理?
// 用getResponseCode可以获取
URL
返回状态码String surl
= "";try { surl
="你的url"; URL url = new URL(surl);