Q1:数据库
由于数据有点多,我们在这就不展示了(需要的联系我,我发给你)
i
这是里面所用到的一些架包,包等等。相信大家对这一块都已经了解了,我就不说废话了。
Q2:html文件
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <script src=js/jquery-1.11.3.js></script> 身份证号码:<input type="text" id="idCard"/> 出生日期:<input type="text" id="birthday"/> 性别:<input type="radio" name="sex" value="男" id="nan"/>男<input type="radio" name="sex" value="女" id="nv"/>女 籍贯:<input type="text" id="place"/> <input type="button" value="确定" id="btnok"/> <script> var app={ select:function(){ var cardid=$("#idCard").val(); var place=cardid.substring(0,6); $.ajax({ type:'post', url:'S_area_codeaction?action=select', data:{areaCode:place}, success:function(data){ console.log(data); $("#place").val(data[0].detail); } }); }, start:function(){ $("#btnok").click(function(){ var cardid=$("#idCard").val(); var nian=cardid.substring(6,10);//1998 var yue=cardid.substring(10,12); var ri=cardid.substring(12,14); var birthdays=nian+"-"+yue+"-"+ri; /* var a=IsDate(birthdays); */ /* if(a){ */ $("#birthday").val(nian+"年"+yue+"月"+ri+"日"); var sex=cardid.substring(16,17); if(sex%2==0){ $("#nv").prop("checked",true); }else{ $("#nan").prop("checked",true); } app.select(); /* } */ }); } }; app.start();
//下面可以判断日期: /* function IsDate(str) { arr = str.split("-"); if(arr.length == 3) { intYear = parseInt(arr[0],10); intMonth = parseInt(arr[1],10); intDay = parseInt(arr[2],10); if(isNaN(intYear) || isNaN(intMonth) || isNaN(intDay)) { return false; } if(intYear > 2100 || intYear < 1900 || intMonth > 12 || intMonth < 0 || intDay > 31 || intDay < 0) { return false; } if((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && intDay > 30) { return false; } if(intYear % 100 == 0 && intYear % 400 || intYear % 100 && intYear % 4 == 0) { if(intDay > 29) return false; } else { if(intDay > 28) return false; } return true; } return false; } */ </script> </body> </html>
Q3:Servlet(S_area_codeaction)
package action; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.bo.S_area_codeboimpl; import com.vo.S_area_code; import jsonUtil.JsonUtils; @WebServlet("/S_area_codeaction") public class S_area_codeaction extends HttpServlet { private static final long serialVersionUID = 1L; public S_area_codeaction() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("application/json;charset=utf-8"); String action=request.getParameter("action"); if(action.equals("select")) { select(request,response); } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } //查询 public void select(HttpServletRequest request, HttpServletResponse response) { S_area_codeboimpl si=new S_area_codeboimpl(); int areaCode=Integer.parseInt(request.getParameter("areaCode")); List<S_area_code> lists=si.getAllList(areaCode); List&