亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

瀏覽器顯示500錯誤

瀏覽器顯示500錯誤

楓夜流螢 2017-12-01 20:11:30
package?Bean; public?class?login?{ private?String?user; private?String?password; public?login(){ super(); } public?String?getUser()?{ return?user; } public?void?setUser(String?user)?{ this.user?=?user; } public?String?getPassword()?{ return?password; } public?void?setPassword(String?password)?{ this.password?=?password; } }package Dao;import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import Bean.login;import Util.DBUtil;public class loginDao { public static ?Bean.login login(String user) throws SQLException{ ? ? ? ? ? ? //static Bean.login根據提示修改 String sql = "select * from user where user_name ='" +user+"'"; Connection con = DBUtil.getConnection(); Statement stmd = con.createStatement(); ResultSet rs = stmd.executeQuery(sql); while(rs.next()){ login u = new login(); ? ? u.setUser(rs.getString("user")); ? ? u.setPassword(rs.getString("password")); ? ? return null; } return null; } }package Servlet;import java.io.IOException;import java.io.PrintWriter;import java.sql.SQLException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.swing.JOptionPane;import Bean.login;import Dao.loginDao;public class loginServlet extends HttpServlet { /** *? */ private static final long serialVersionUID = 6835706189070152812L; /** * Constructor of the object. */ public loginServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { return; } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String user = request.getParameter("user"); String password = request.getParameter("password"); response.setContentType("text/html"); //PrintWriter out = response.getWriter(); try{ login lg = new Bean.login(); lg = loginDao.login("user"); if(user != null){ if(lg.getPassword().endsWith(password)){ request.getRequestDispatcher("index.jsp") .forward(request, response); }else{ request.getRequestDispatcher("login.jsp") .forward(request, response); } }else{ JOptionPane.showMessageDialog(null, "用戶名不存在!"); response.sendRedirect("Login.jsp"); } }catch(SQLException e){ e.printStackTrace(); } } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here }}package Util;import java.sql.*;public class DBUtil { public static Connection getConnection() throws SQLException{ String url = "jdbc:mysql://192.168.100.1:3306/bus"; String user = "root"; String password = ""; Connection con = null; try{ Class.forName("com.mysql.jdbc.Driver"); con=DriverManager.getConnection(url,user,password); }catch(Exception e){ e.printStackTrace(); } return con; } }<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>? <head>? ? <base href="<%=basePath%>">? ??? ? <title>My JSP 'login.jsp' starting page</title>? ?? <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> ? ? <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> -->? </head>? <title>登錄</title>? <body>? ?<form action="servlet/loginServlet" method="post">? ? ? ? ? 用戶名:<input type="text" name="user">? ? ? ? ? ? ?密碼: <input type="text" name="password">? ? ? ? <input type="submit" name="login" value="submit">? ? ? ? ? ? ?? ?</form>? </body></html>
查看完整描述

1 回答

?
慕村4705583

TA貢獻40條經驗 獲得超14個贊

500是服務器錯誤 ?你仔細看下拋的異常

查看完整回答
反對 回復 2017-12-02
  • 1 回答
  • 0 關注
  • 1229 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號