问题描述
- JSP 用户登录处理界面显示空白怎么解决
-
<%@ page language=""java"" contentType=""text/html; charset=GBK""%><%@ page import=""java.sql.*""%><html> <head> <title>业务处理页面</title> </head> <body> <% request.setCharacterEncoding(""GBK""); String name = request.getParameter(""userName""); String pwd = request.getParameter(""pwd""); Connection con = null; Statement stmt = null; ResultSet rs = null; try { Class.forName(""com.mysql.jdbc.Driver""); con =DriverManager.getConnection(""jdbc:mysql://localhost/news1?user=root&password=123456""); stmt = con.createStatement(); String str = ""select * from users where userName='""+name+""' and pwd='""+pwd+""' ""; rs = stmt.executeQuery(str); if(rs.next()){ if(""admin"".equals(name)) response.sendRedirect(""admin.jsp""); else response.sendRedirect(""index.jsp""); } else { response.sendRedirect(""error.jsp""); response.sendRedirect(""regist.jsp""); } } catch (Exception e) { e.printStackTrace(); } %> </body></html>
如上,是用户登录的处理jsp代码,请问哪里出问题了?
解决方案
先看下http网址的路径是否正确,再看下你填写的user/pwd是否和数据库相同。
解决方案二:
显示空白,如果你的控制台没有报错的话 你看下你的URL地址是多少。
解决方案三:
con =DriverManager.getConnection(""jdbc:mysql://localhost/news1?user=root&password=123456"");
这个用法对吗?
时间: 2024-09-08 11:25:06