這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)使用Vue怎么調(diào)用后端java接口,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
創(chuàng)新互聯(lián)公司秉承實現(xiàn)全網(wǎng)價值營銷的理念,以專業(yè)定制企業(yè)官網(wǎng),網(wǎng)站制作、網(wǎng)站設(shè)計,微信小程序定制開發(fā),網(wǎng)頁設(shè)計制作,手機網(wǎng)站制作,營銷型網(wǎng)站幫助傳統(tǒng)企業(yè)實現(xiàn)“互聯(lián)網(wǎng)+”轉(zhuǎn)型升級專業(yè)定制企業(yè)官網(wǎng),公司注重人才、技術(shù)和管理,匯聚了一批優(yōu)秀的互聯(lián)網(wǎng)技術(shù)人才,對客戶都以感恩的心態(tài)奉獻自己的專業(yè)和所長。
后端接口代碼:
package controller; import net.sf.json.JSONObject; import util.DBUtil; 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 javax.servlet.http.HttpSession; import java.io.IOException; import java.sql.Connection; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.ResultSet; @WebServlet(name = "login",urlPatterns = "/login") public class login extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(true); String username = request.getParameter("username"); String password = request.getParameter("password"); DBUtil dbUtil = new DBUtil(); Connection connection = dbUtil.getConnection(); PreparedStatement preparedStatement; ResultSet rs; String psw=""; String sql = "select password from `user` where username=?"; try { preparedStatement = connection.prepareStatement(sql); preparedStatement.setInt(1,Integer.parseInt(username)); rs = preparedStatement.executeQuery(); while (rs.next()){ psw = rs.getString("password"); } } catch (Exception e){ e.printStackTrace(); } if (password.equals(psw)){ session.setAttribute("username",username); response.getWriter().print("true"); } else response.getWriter().print("false"); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } }
前端調(diào)用:
Login 智慧圖書管理平臺記住密碼
上述就是小編為大家分享的使用Vue怎么調(diào)用后端java接口了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。