GET
Map<String, Object> map = new HashMap<String, Object>();
String type = req.getParameter("type");
System.out.println("fsdfsdfsdsddsf" + type);
String resultStr = null;
if (type.equals("login")) {
String phoneNum = req.getParameter("phoneNum");
String pass = req.getParameter("pass");
UserScerviceImpl userScervice = new UserScerviceImpl();
userInfoModel userTestModel = new userInfoModel();
String userPhoneNum = phoneNum;
String userPass = pass;
userTestModel.setUserName(userPhoneNum);
userTestModel.setUserPass(userPass);
map = userScervice.userLogin(userTestModel);
}
POST
ServletInputStream servletInputStream = req.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(); // 请求体内容
HashMap hashMap = JSON.parseObject(strContent, HashMap.class);
String s = hashMap.get("phoneNum").toString();
System.out.println("post请求"+s);
网友评论