package com.PIM.dao;public class UserDao {????public boolean exsit(String name) throws SQLException { Connection conn=DBUtil.getConnection(); String sql="" + " select * from imooc_goddess " + " where user_name=? "; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, name); ResultSet rs=ptmt.executeQuery(); if(rs!=null){ return true; } else{ return false; }}jsp 頁(yè)面:<%@ page language="java" import="java.util.* ,com.PIM.dao.*,com.PIM.model.*" contentType ="text/html; charset=utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; String password = null;?request.setCharacterEncoding("utf-8"); //只是針對(duì)POST方式提交的請(qǐng)求,對(duì)GET方式無(wú)效。?response.setContentType("text/html;charset=utf-8");?UserDao ud= new UserDao();//報(bào)錯(cuò)的地方~~~~~~~~~~~~~~~?。。。。。。?!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~?boolean a = ud.exsit("565203087");//寫(xiě)死,數(shù)據(jù)庫(kù)中有這條數(shù)據(jù)。但是調(diào)用總是報(bào)錯(cuò)。 if(a){ request.getRequestDispatcher("main.jsp").forward(request,response);//服務(wù)器內(nèi)部轉(zhuǎn)發(fā) } else{ response.sendRedirect("Registion.jsp");//請(qǐng)求重定向 }%>main 方法:UserDao ud = new UserDao();boolean a = ud.exsit("565203087"); System.out.println(a);//一切正常,服務(wù)臺(tái)能返回true????
添加回答
舉報(bào)
0/150
提交
取消