- get请求方式:
Long houseId = Long.parseLong(request.getParameter("houseId"));
get请求示例: http://localhost:80/buildHouseByHouseId?houseId=123
- post请求方式
ServletInputStream servletInputStream = request.getInputStream();
StringBuilder content = new StringBuilder();
byte[] b = new byte[1024];
int lens;
while ((lens = servletInputStream.read(b)) > 0) {
content.append(new String(b, 0, lens));
}
String strContent = content.toString(); // 请求体内容
post请求示例:
http://localhost:80/house 传一个字符串(House实体转成的json字符串)