使用Vue怎么调用后端java接口-创新互联
这期内容当中小编将会给大家带来有关使用Vue怎么调用后端java接口,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

后端接口代码:
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 {
}
}前端调用:
Login 智慧图书管理平台
记住密码![]()
上述就是小编为大家分享的使用Vue怎么调用后端java接口了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联成都网站设计公司行业资讯频道。
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
本文名称:使用Vue怎么调用后端java接口-创新互联
网页链接:http://www.scyingshan.cn/article/cegdde.html


咨询
建站咨询
