jsp登录检测运行显示空白页面~

wlhtjht 2012-08-24 08:06:11
代码如下
<%@ page import="com.mysql.jdbc.Driver" %>
<%@ page import="java.sql.*"%>
<%@ page language = "java"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");



%>
<%
if (username != null) { //如果用户名不为空,根据它来查试试
try {
%>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/t", "root", "1");
Statement pstmt = conn.createStatement();
String sql = "select * from w "+" where w_name='" + username + "'" + " and w_password=‘" + password + "’";//查找username。password对应的数据

// pstmt.setString(1,request.getParameter("w_name"));
//pstmt.setString(2,request.getParameter("w_password"));
ResultSet rs = pstmt.executeQuery(sql); // 查询
if(rs.next()) //如果有数据表示可以执行
{ session.setAttribute( "login" , "ok" ); // 验证通过之后,跳转到后续页面
session.setAttribute( "w_name" ,username);


%>
<jsp:forward page="hst5.jsp">
<jsp:param name="" value=""/>
</jsp:forward>
<%
}
else {
%>
<a href="hst1.jsp">账户密码错误,请重新登录</a>

<%
}

} catch (Exception e) {
e.printStackTrace();
}

}
%>

</body>
</html>



进入页面时是空白的。看源代码的时候。只是body之间是空白的。请问。这个事什么问题啊。。。。
...全文
142 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lynnlovemin 2012-08-24
  • 打赏
  • 举报
回复
LS说的有道理
  • 打赏
  • 举报
回复
String username = request.getParameter("username");
System.out.println(username );
加一句打印、看看username传递进来没、

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧