Appcan与后台数据交互,登录例子

1.appcan界面(login.html)

假定后台路径为:http://localhost:8080/LabManageSystem/appcan/login/loginHandle.jsp,其中LabManageSystem为项目名称,appcan/login为项目下的文件夹,

loginHandle.jsp就是最里面login文件夹下的处理appcan用户名和密码的JSP文件。

 

appcan界面(login.html)



   
       
       
       
       
       
       
       
       
       
       
   
   
       


           

               

                   

                       

                       

                           
                       

                   

               

               

                   

                       

                       

                           
                       

                   

               

               


                   

                        登 录
                   

               

       


       
       
       

       
       
   
   

 

后台处理:loginHandle.jsp

 

<%@page import="java.io.PrintWriter"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
 pageEncoding="utf-8"%>
<%@page import="service.*"%>
<%@page import="service.impl.*"%>
<%@page import="service.exception.*"%>
<%@page import="entity.*"%>
<%@page import="factory.*"%>
<%@page import="rowmapper.*"%>
<%@page import="java.util.*"%>
<%@page import="util.*"%>
<%@page import="java.text.*"%>





登录处理


<%!private UserService userService = ServiceFactory.getUserService();%>

<%
 //设置编码
 request.setCharacterEncoding("utf-8");
 PrintWriter pw = response.getWriter();
 String username = request.getParameter("username");
 String password = request.getParameter("password");
 User u = userService.login(username, password);
 if (null != u) {
  pw.write("1");//登录成功,标记为1
 }else{
  pw.write("账号或密码错误!");
 }
 pw.flush();
 pw.close();
%>

你可能感兴趣的:(Appcan与后台数据交互,登录例子)