導航:首頁 > 編程語言 > 登錄參數jsp

登錄參數jsp

發布時間:2023-08-04 19:14:01

jsP頁面獲取系統登錄用戶信息

登錄的時候需要在後台查詢資料庫驗證,驗證的同時查詢到這條記錄,把身份證號返回,存在session里,在頁面就可以拿到

❷ 在jsp頁面中如何獲取Servlet中的參數

可以使用getAttribute()方法和getParameter()方法,區別在於,getAttribute()方法是從request中得到參數,getParameter()方法是從url中得到參數

❸ jsp中點擊登錄彈出對話框如何實現

實現的方法有很多啊!最簡單的就是用javaScript
在JSP頁面中加一局<script>alert("對話框")</script>

❹ 在jsp中,如何實現普通用戶和管理員登陸後跳轉到不同的點jsp頁面

在jsp中可以通過角色控製表跳轉不同的頁面。
參考代碼如下:

package myservlet;
import mybean.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class IsLogin extends HttpServlet{
public void init(ServletConfig config) throws ServletException{
super.init(config);
}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
//接收參數
String user=request.getParameter("user");
String password=request.getParameter("password");
String actor=request.getParameter("actor");
//載入驅動,建立連接
Connection con;
Statement sql;
ResultSet rs;
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}catch(Exception e){
System.out.print(e);
}

try{
String uri="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=student";
con=DriverManager.getConnection(uri,"sa","940712");//資料庫的登錄名 sa 940712
sql=con.createStatement();
//通過if語句判斷角色,將其賬號密碼與資料庫的userInf內的信息進行比對(角色的賬號密碼統一存儲在UserInf表中)
//若正確,轉發至角色對應的登錄成功界面;若沒有,統一轉發至出錯界面,提供返回鏈接供重新登錄
if(actor=="student"){
rs=sql.executeQuery("select userIs,password from userInf where actor='student'");
while(rs.next()){
if(user==rs.getString(1) && password==rs.getString(2)){
RequestDispatcher dispatcher=request.getRequestDispatcher("loginSuccessS.jsp");
dispatcher.forward(request,response);
}
}
RequestDispatcher dispatcher=request.getRequestDispatcher("loginError.jsp");
dispatcher.forward(request,response);
}
//普通用戶角色控制
else if(actor=="teacher"){
rs=sql.executeQuery("select userIs,password from userInf where actor='teacher'");
while(rs.next()){
if(user==rs.getString(1) && password==rs.getString(2)){
RequestDispatcher dispatcher=request.getRequestDispatcher("loginSuccessT.jsp");
dispatcher.forward(request,response);
}
}
RequestDispatcher dispatcher=request.getRequestDispatcher("loginError.jsp");
dispatcher.forward(request,response);
}
//管理員角色控制
else if(actor=="admin"){
rs=sql.executeQuery("select userIs,password from userInf where actor='admin'");
while(rs.next()){
if(user==rs.getString(1) && password==rs.getString(2)){
RequestDispatcher dispatcher=request.getRequestDispatcher("loginSuccessA.jsp");
dispatcher.forward(request,response);
}
}
RequestDispatcher dispatcher=request.getRequestDispatcher("loginError.jsp");
dispatcher.forward(request,response);
}
}catch(SQLException e){
//System.out.print("您的賬號或密碼錯誤,請返回重新輸入");
RequestDispatcher dispatcher=request.getRequestDispatcher("loginError.jsp");
dispatcher.forward(request,response);
}
}
}

閱讀全文

與登錄參數jsp相關的資料

熱點內容
u盤驅動在哪個文件夾里 瀏覽:938
華為手機跟蘋果手機怎麼克隆app 瀏覽:172
cad文件為什麼顯示文件名是否正確 瀏覽:174
程序配置文件能自動轉換成txt 瀏覽:985
r4燒錄卡不同版本 瀏覽:962
怎麼升級qq群為2000 瀏覽:347
微信己冊除的文件怎樣找回來 瀏覽:715
蘋果美國賬號共享2017 瀏覽:252
ps文件修改後打開還是原圖 瀏覽:220
燒卡機蘋果4微信qq哪裡下載 瀏覽:780
ug120找不到指定文件 瀏覽:522
cda文件怎麼轉換成mp3格式 瀏覽:702
青島hpv疫苗在哪個app預約 瀏覽:881
雙十一成交額2021數據在哪裡看 瀏覽:631
蘋果手機怎麼打開移動數據 瀏覽:637
文件掃描成圖片是彩色的嗎 瀏覽:50
編程里的comply什麼意思 瀏覽:91
電腦上面點了禁用網路怎麼改回來 瀏覽:28
javacatch執行 瀏覽:182
ps軟體文件名字 瀏覽:184

友情鏈接