1.controller不是以功能分区,而是用前端传来的数据来区分,用的同一类数据,此一类数据的操作,应该放在一个分区中。
2.insert时,主键id设置的数据库自增,为什么要给它赋null?

设为null时,数据库自动递增
3.302 重定向
HttpResponse response = null;
response = client.execute(httpPost);
//----------判断是否重定向开始
int code = response.getStatusLine().getStatusCode();
String newUrL ="";
if (code == 301) {
Header header = response.getFirstHeader("location"); // 跳转的目标地址在 HTTP-HEAD 中
newUrL = header.getValue(); // 这就是跳转后的地址,再向这个地址发出新申请,以获取跳转后的信息。
System.out.println(newUrL);
System.out.println(code);
httppost = new HttpPost(newUrL);
httppost.setHeader("Content-Type", "application/json;charset=UTF-8");
httppost.setEntity(strEntity);
response = httpclient.execute(httppost);
code = response.getStatusLine().getStatusCode();
System.out.println("login"+code);
}
//------------重定向结束
HttpEntity entity=response.getEntity();
String strReturn = EntityUtils.toString(entity, "UTF-8");
JSONObject jsonReturn =JSON.parseObject(strReturn);
String certificate=jsonReturn.getString("ficate");
String certificatekey=jsonReturn.getString("ficatekey");
本文探讨了控制器设计原则,解释了为何在插入操作中将主键ID设为NULL以便利用数据库自增特性。此外,详细介绍了如何处理HTTP 302重定向,包括通过检查响应状态码和读取Location头信息来实现自动跟随重定向。
458





