日期:2014-05-17  浏览次数:20707 次

急求请大侠帮忙呀!!!
这是数据处理层代码:
<%-- 
    Document   : loginCheck
    Created on : 2013-11-16, 13:50:28
    Author     : Administrator
--%>

<%@page import="java.sql.*"%>%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>数据处理页面</title>
    </head>
    <body>
        <%
            String userName =new String(request.getParameter("UserName").getBytes("ISO-8859-1"),"UTF-8");
            String password =new String(request.getParameter("UserPwd").getBytes("ISO-8859-1"),"UTF-8");
            Connection con = null;
            Statement st = null;
            ResultSet rs = null;
            if(userName.equals("")) {
                response.sendRedirect("http://localhost:8084/MYWEB/Login/login.jsp");
            }
            try{
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                /*url后面加的?useUnicode=true&characterEncoding=gbk,是为了处理向数据库中添加数据时出现乱码的问题。*/
                String url="jdbc:mysql://localhost:3306/bbs?useUnicode=true&characterEncoding=gbk";
                //String url="jdbc:mysql://localhost:3306/eims?user=root&&password=root";
                con=DriverManager.getConnection(url,"root","213124");
                st=con.createStatement();
                String query="select * from Tb_user where UserName='" + userName + "'";
                rs=st.executeQuery(query);
                if(rs.next()){
                    String query2 ="select * from Tb_user where UserPwd='" + password + "'";
                    rs=st.executeQuery(query2);