| 主機參考:VPS測評參考推薦/專注分享VPS服務(wù)器優(yōu)惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務(wù),查看詳情! |
| 我們發(fā)布的部分優(yōu)惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關(guān)文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作 |
相關(guān)推薦:《小程序開發(fā)教程》
服務(wù)器源碼
考慮到很多朋友私信我詢問后端代碼。 我很高興能夠幫助這么多人。 但由于各種情況,我們未能將其與客戶端代碼一起發(fā)布。 在這里,我們將把代碼發(fā)布到GitHub上,以便任何人都可以輕松下載和研究。 這里使用了Java servlet。 它是在 Web 服務(wù)器或應(yīng)用程序服務(wù)器上運行的程序,作為來自 Web 瀏覽器或其他 HTTP 客戶端的請求與 HTTP 服務(wù)器上的數(shù)據(jù)庫或應(yīng)用程序之間的中間層。 數(shù)據(jù)庫使用MySQL,持久層使用Java的原生API JDBC。 不使用任何框架,因此初學(xué)者可以學(xué)習(xí)并更深入地了解網(wǎng)絡(luò)的工作原理及其原理。 GitHub地址:傳送門關(guān)鍵代碼為:
/** * Servlet實現(xiàn)類Login */@WebServlet("/Login") public class Login extends HttpServlet {private staticfinallongserialVersionUID=1L;private staticfinalString APPID=" xxxxxxxxx";Private static Final string SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxx"; /** * 默認構(gòu)造函數(shù)。 */ public Login() { // TODO 自動-生成的構(gòu)造函數(shù)存根 }/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//éè?à???ó±à? request.setCharacterEncoding("utf-8"); "text/html;charset=utf-8"); /* éè??ìó|í·?êDíajax? /* D?o?±íê??ùóDμ?òìóò???ó??? Cam */ response.setHeader("Access-Control-Allow-Methods", "GET,POST"); // System.out . flag); if("登錄".equals(flag)) { String code=request.getParameterr("js_code"); 字符串 URL = "https://api.weixin.qq.com/sns/jscode2session?appid="+APPID+"&secret="+SECRET+"&js_code="+ 代碼 +"&grant_type=authorization_code " ; JSONObject sjson=CommonUtil.httpsRequest(url, "GET", null); /*String String 會話密鑰 = ""; if (sjson != null) { try { openid = sjson.getString ("openid"); " ); session_key=sjson.getString("session_key");} catch (異常 e) {System.out.println("òμ??2ù×÷ê§°ü");e.printStackTrace();}} else {System. out .println("code\");} System.out.println(session_key+" "+openid);*/ /*Map result = new HashMap(); result.put("res", "test"); result.put("msg", "oóìò?ê?μ?");*/ // 字符串 json = new Gson().toJson(sjson); // System.out.println(json); Writer out=response.getWriter(); out.write(sjson.toString()); if("init".equals(flag)) { StudentDAO StudentDAO=new StudentDAO(); string userid=request.getParameter("userid"); { 嘗試 res=studentDAO.findCheck(userid); } catch (異常 e) { e.printStackTrace(); result = new HashMap(); result.put("res", res); ”°óììString json = new Gson().toJson(result); //·μ?????мD(zhuǎn)?D?3Dò Writer out = response.getWriter(); out.write(json) } if( "student".equals(flag)) { StudentDAO StudentDAO=new StudentDAO(); String StudentName=request.getParameter("sname"); .getParameter("snum"); new Date()); 嘗試 {int a=studentDAO.create(student);if(a!=0) {System.out. println("2?è?3é1?");}} catch (異常 e) {e .printStackTrace() ;} } if("Teacher".equals(flag)) { TeacherDAO TeacherDAO=new TeacherDAO(); String userid=request.getParameter("userid"); String TeacherID=request.getParameter("tnum"); , TeacherName,new Date()); try {int a=TeacherDAO.create(tea);if(a!=0) {System.out.println("2?è?3é1?");}} catch (Exception e) {e . printStackTrace();} } if( "Guide".equals(flag)) { StudentDAO StudentDAO=new StudentDAO(); String userid=request.getParameter("userid"); = true; 字符串狀態(tài) =“”; { 嘗試 res=studentDAO.findCheck(userid); } catch (異常 e) { e.printStackTrace(); }if(res) { state="Student"; } else{TeacherDAO TeacherDAO=new TeacherDAO();嘗試 {res=TeacherDAO.findCheck(userid);} catch (異常 e) {e.printStackTrace();}if(res ) { state="Teacher"; }else {state="none";}} String json = new Gson().toJson(state); 寫入輸出 = response.getWriter(); out.flush(); if("myInfo".equals(flag)) { String userid=request.getParameter("userid"); new StudentDAO(); 嘗試 {List list=studentDAO.myInfo(userid);Map result = new HashMap(&);quot;backName",list.get(0)); result.put("backNum", list.get(1)); String json = new Gson().toJson(result); //·μ???μ??? ? Writer out = response.getWriter(); out.write(json); out.flush();} catch (Exception e) {e.printStackTrace();} } }/** * @see HttpServlet# doPost(HttpServletRequest request, HttpServletResponse response) */protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO自動-生成方法stubdoGet(request, response);}}
APPID和用戶最近因為我不太關(guān)注我的博客,而且收到很多詢問,所以我無法回復(fù)私信,剩下的完全取決于您的個人利益,不應(yīng)該用于商業(yè)目的。請。
下載微信App
微信是一款支持通過手機網(wǎng)絡(luò)發(fā)送語音消息、視頻、照片和文字的移動通訊軟件。 微信帶來了全新的移動通信體驗,您可以單獨或群組聊天,還可以根據(jù)您的地理位置查找附近的人。 有需要的朋友,請快來保存您的下載體驗吧!
這幾篇文章你可能也喜歡:
- 如何在微信系的父母(頁面通信)中實現(xiàn)兒童傳輸參數(shù)(微信Mini Program Navigateto傳輸參數(shù))
- 如何操作微信迷你計劃購物中心系統(tǒng)? (使用Mini計劃購物中心的教程)
- 關(guān)于如何在Mini程序中創(chuàng)建頁面QR碼的簡要說明(如何為Mini Program Page生成QR碼)
- 簡單分析如何動態(tài)創(chuàng)建迷你程序代碼(在微信中更改動態(tài)圖像)
- 如何檢查微信系的無線密碼(如何檢查微信小程序的WiFi密碼)
本文由主機參考刊發(fā),轉(zhuǎn)載請注明:分享微信小程序簽到考勤后臺代碼(如何獲取小程序考勤位置) http://www.k2270.com/123517.html
主機參考

















評論前必須登錄!
注冊