欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java登入的代碼 登錄java代碼

java ATM登陸循環(huán)代碼?

下面是一個簡單的登錄示例:

公司主營業(yè)務(wù):成都網(wǎng)站制作、成都網(wǎng)站建設(shè)、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。成都創(chuàng)新互聯(lián)公司是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。成都創(chuàng)新互聯(lián)公司推出臨清免費做網(wǎng)站回饋大家。

代碼復(fù)制展示:

public class ATMLogin {

public static void main(String[] args) {

// 設(shè)置用戶名和密碼

String username = "gqk";

String password = "520";

// 最多可以登錄 3 次

for (int i = 0; i 3; i++) {

// 讀取用戶輸入的用戶名和密碼

Scanner in = new Scanner(System.in);

System.out.print("請輸入用戶名:");

String inputUsername = in.nextLine();

System.out.print("請輸入密碼:");

String inputPassword = in.nextLine();

// 檢查用戶名和密碼是否正確

if (inputUsername.equals(username) inputPassword.equals(password)) {

System.out.println("歡迎" + username + "登錄!");

break; // 登錄成功,退出循環(huán)

} else {

System.out.println("用戶名或密碼錯誤,請重新輸入!");

}

}

// 如果 3 次登錄都失敗,則提示用戶

System.out.println("卡片已經(jīng)被鎖,請聯(lián)系客服人員!");

}

}

回答不易望請采納

Java如何登錄token的代碼是什么?

首先是Token主類。類很簡單

package com.company.util;

import java.util.ArrayList;

import javax.servlet.http.HttpSession;

public class Token {

private static final String TOKEN_LIST_NAME = "tokenList";

public static final String TOKEN_STRING_NAME = "token";

private static ArrayList getTokenList(HttpSession session) {

Object obj = session.getAttribute(TOKEN_LIST_NAME);

if (obj != null) {

return (ArrayList) obj;

} else {

ArrayList tokenList = new ArrayList();

session.setAttribute(TOKEN_LIST_NAME, tokenList);

return tokenList;

}

}

private static void saveTokenString(String tokenStr, HttpSession session) {

ArrayList tokenList = getTokenList(session);

tokenList.add(tokenStr);

session.setAttribute(TOKEN_LIST_NAME, tokenList);

}

private static String generateTokenString(){

return new Long(System.currentTimeMillis()).toString();

}

/** *//**

* Generate a token string, and save the string in session, then return the token string.

*

* @param HttpSession

* session

* @return a token string used for enforcing a single request for a particular transaction.

*/

public static String getTokenString(HttpSession session) {

String tokenStr = generateTokenString();

saveTokenString(tokenStr, session);

return tokenStr;

}

/** *//**

* check whether token string is valid. if session contains the token string, return true.

* otherwise, return false.

*

* @param String

* tokenStr

* @param HttpSession

* session

* @return true: session contains tokenStr; false: session is null or tokenStr is id not in session

*/

public static boolean isTokenStringValid(String tokenStr, HttpSession session) {

boolean valid = false;

if(session != null){

ArrayList tokenList = getTokenList(session);

if (tokenList.contains(tokenStr)) {

valid = true;

tokenList.remove(tokenStr);

}

}

return valid;

}

}

在jsp頁面端。

首先import該類:

%@ page import="com.company.util.Token" %

表單包含隱藏的token字符串:

form

input type="hidden" name="%=Token.TOKEN_STRING_NAME %" value="%=Token.getTokenString(session) %"

/form

在Servlet中添加如下代碼。

if(Token.isTokenStringValid(request.getParameter(Token.TOKEN_STRING_NAME), request.getSession())){

//進行正常業(yè)務(wù)流程

求JAVA實現(xiàn)用戶登錄界面代碼?

你要先學(xué)會截圖哦,你發(fā)的看不清楚,重新寫了一個你參考參考!

import java.awt.GridLayout;

import javax.swing.ButtonGroup;

import javax.swing.JButton;

import javax.swing.JComboBox;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JRadioButton;

import javax.swing.JTextField;

public class Day30A extends JFrame {

private static final long serialVersionUID = 1L;

private JLabel labelName,labelId,labelPass,labelMoney,labelSelect,labelCar;

private JComboBoxString jcb;

private JPanel jp1,jp2,jp3,jp4,jp5,jp6,jp7;

private ButtonGroup btg;

private JRadioButton jr1,jr2;

Day30A(){

this.setTitle("注冊賬戶");

this.setLayout(new GridLayout(7,1));

this.setSize(300,280);

this.setLocationRelativeTo(null);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

init();

this.setVisible(true);

}

private void init() {

String str="卡片類型1,卡片類型2,卡片類型3,卡片類型4,卡片類型5";

jcb=new JComboBox(str.split(","));

labelId=new JLabel("賬號: ");

labelName=new JLabel("姓名: ");

labelPass=new JLabel("密碼: ");

labelMoney=new JLabel("開戶金額:");

labelSelect=new JLabel("存款類型:");

labelCar=new JLabel("卡片類型:");

addFun1();

addFun2();

}

private void addFun2() {

this.add(jp1);

this.add(jp2);

this.add(jp3);

this.add(jp4);

this.add(jp5);

this.add(jp6);

this.add(jp7);

}

private void addFun1() {

jp1=new JPanel();

jp1.add(labelId);

jp1.add(new JTextField(15));

jp2=new JPanel();

jp2.add(labelName);

jp2.add(new JTextField(15));

jp3=new JPanel();

jp3.add(labelPass);

jp3.add(new JTextField(15));

jp4=new JPanel();

jp4.add(labelMoney);

jp4.add(new JTextField(13));

jp5=new JPanel();

jp5.add(labelSelect);

btg=new ButtonGroup();

jr1=new JRadioButton("定期");

jr2=new JRadioButton("活期",true);

btg.add(jr1);

btg.add(jr2);

jp5.add(jr1);

jp5.add(jr2);

jp6=new JPanel();

jp6.add(labelCar);

jp6.add(jcb);

jp7=new JPanel();

jp7.add(new JButton("確定"));

jp7.add(new JButton("取消"));

}

public static void main(String[] args) {

new Day30A();

}

}

登陸界面的java代碼怎么寫?

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.sql.*;

class LoginFrm extends JFrame implements ActionListener

{

JLabel lbl1=new JLabel("用戶名");

JLabel lbl2=new JLabel("密碼");

JTextField txt=new JTextField(15);

JPasswordField pf=new JPasswordField();

JButton btn1=new JButton("確定");

JButton btn2=new JButton("取消");

public LoginFrm()

{

this.setTitle("登陸");

JPanel jp=(JPanel)this.getContentPane();

jp.setLayout(new GridLayout(3,2,10,10));

jp.add(lbl1);jp.add(txt);

jp.add(lbl2);jp.add(pf);

jp.add(btn1);jp.add(btn2);

btn1.addActionListener(this);

btn2.addActionListener(this);

}

public void actionPerformed(ActionEvent ae)

{

if(ae.getSource()==btn1)

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:MyDB","","");

Statement cmd=con.createStatement();

ResultSet rs=cmd.executeQuery("select * from loginAndpassword where login='"+txt.getText()+"' and password='"+pf.getText()+"'");

if(rs.next())

{

JOptionPane.showMessageDialog(null,"登陸成功!");

}

else

JOptionPane.showMessageDialog(null,"用戶名或密碼錯誤!");

} catch(Exception ex){}

if(ae.getSource()==btn2)

{

txt.setText("");

pf.setText("");

}

}

}

public static void main(String arg[])

{

JFrame.setDefaultLookAndFeelDecorated(true);

LoginFrm frm=new LoginFrm();

frm.setSize(400,200);

frm.setVisible(true);

}

}

用java寫一個登錄界面的代碼,哪位大神會啊,謝謝。

import?java.awt.Dimension;

import?java.awt.Toolkit;

import?java.awt.event.ActionEvent;

import?java.awt.event.ActionListener;

import?javax.swing.JButton;

import?javax.swing.JFrame;

import?javax.swing.JLabel;

import?javax.swing.JOptionPane;

import?javax.swing.JPasswordField;

import?javax.swing.JTextField;

public?class?Test26?{

public?static?void?main(String[]?args)?{

final?String?userName?=?"abc";

final?String?passwrod?=?"123";

JFrame?jFrame?=?new?JFrame("登陸界面");

Dimension?dimension?=?Toolkit.getDefaultToolkit().getScreenSize();

jFrame.setBounds(((int)dimension.getWidth()?-?200)?/?2,?((int)dimension.getHeight()?-?300)?/?2,?200,?150);

jFrame.setResizable(false);

jFrame.setLayout(null);

jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JLabel?label1?=?new?JLabel("姓名");

label1.setBounds(10,?10,?100,?30);

jFrame.add(label1);

JLabel?label2?=?new?JLabel("密碼");

label2.setBounds(10,?40,?100,?30);

jFrame.add(label2);

final?JTextField?text1?=?new?JTextField();

text1.setBounds(50,?15,?130,?20);

jFrame.add(text1);

final?JPasswordField?text2?=?new?JPasswordField();

text2.setBounds(50,?45,?130,?20);

jFrame.add(text2);

JButton?button?=?new?JButton("Login");

button.setBounds(10,?75,?170,?40);

button.addActionListener(new?ActionListener()?{

@Override

public?void?actionPerformed(ActionEvent?e)?{

if(userName.equals(text1.getText())??passwrod.equals(text2.getText()))?{

JOptionPane.showMessageDialog(null,?"登陸成功誤",?"提示",?JOptionPane.INFORMATION_MESSAGE);

}?else?{

JOptionPane.showMessageDialog(null,?"錯誤",?"提示",?JOptionPane.ERROR_MESSAGE);

text1.setText("");

text2.setText("");

}

}

});

jFrame.add(button);

jFrame.setVisible(true);

}

}

我有一個微信公眾號,經(jīng)常會分享一些Java技術(shù)相關(guān)的干貨,還有一些學(xué)習(xí)資源。

如果你喜歡我的分享,可以用微信搜索“Java團長”或者“javatuanzhang”關(guān)注。

本文名稱:java登入的代碼 登錄java代碼
文章起源:http://chinadenli.net/article2/hepoic.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站網(wǎng)站設(shè)計品牌網(wǎng)站建設(shè)服務(wù)器托管移動網(wǎng)站建設(shè)營銷型網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司