系统登录
系统登录
这个是首页
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
login
<%System.out.println("111111"); %>
<% String username=request.getParameter("uid");
String password=request.getParameter("upwd");
System.out.println("111");
if(username!=null && !username.equals("")){
try{
Class.forName("org.gjt.mm.mysql.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost/logincheck","root","123456");
Statement stmt=conn.createStatement();
String sql="select * from users where username=';"+username+"';";
sql+=" and password=';"+password+"';";
ResultSet rs=stmt.executeQuery(sql);
if(rs.next()){
session.setAttribute("login","ok");
session.setAttribute("uname",username); %>
<% }else
out.println("错误的用户名或密码");
out.println("返回");
}
catch(Exception ee){
ee.printStackTrace(); }
}else{
out.println("请先登录!");
out.println("返回");
}
%>
这个是login.jsp
首页写好以后,怎么jsp里面是空的?
截图如下:
登录后停留在login.jsp页面,并且页面为空
试过在body中<% %>以外的地方添加文字,可以显示 |