1. 重庆云诚科技 > 数码百科 >

〔web登录页面设计〕登录页面设计代码

导读jsp登陆界面源代码本文贡献者:【秋水潺潺】, 疑问关键字:web登录页面设计, 下面就让重庆云诚科技小编为你解答,希望本文能找到您要的答案!答1、login.jsp文件<%@ page language=&...

本篇文章给大家谈谈web登录页面设计,以及登录页面设计代码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

jsp登陆界面源代码

本文贡献者:【秋水潺潺】, 疑问关键字:web登录页面设计, 下面就让重庆云诚科技小编为你解答,希望本文能找到您要的答案!

1、login.jsp文件

<%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%>

<%@ page import="java.util.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>登录页面</title>

</head>

<body>

<form name="loginForm" method="post" action="judgeUser.jsp">

<table>

<tr>

<td>用户名:<input type="text" name="userName" id="userName"></td>

</tr>

<tr>

<td>密码:<input type="password" name="password" id="password"></td>

</tr>

<tr>

<td><input type="submit" value="登录" style="background-color:pink"> <input

type="reset" value="重置" style="background-color:red"></td>

</tr>

</table>

</form>

</body>

</html>

2、judge.jsp文件

<%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%>

<%@ page import="java.util.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>身份验证</title>

</head>

<body>

<%

request.setCharacterEncoding("GB18030");

String name = request.getParameter("userName");

String password = request.getParameter("password");

if(name.equals("abc")&& password.equals("123")) {

3、afterLogin.jsp文件

%>

<jsp:forward page="afterLogin.jsp">

<jsp:param name="userName" value="<%=name%>"/>

</jsp:forward>

<%

}

else {

%>

<jsp:forward page="login.jsp"/>

<%

}

%>

</body>

</html>

<%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>登录成功</title>

</head>

<body>

<%

request.setCharacterEncoding("GB18030");

String name = request.getParameter("userName");

out.println("欢迎你:" + name);

%>

</body>

</html>

扩展资料:

java web登录界面源代码:

1、Data_uil.java文件

import java.sql.*;

public class Data_uil 

{

public  Connection getConnection()

{

try{

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

}catch(ClassNotFoundException e)

{

e.printStackTrace();

}

String user="***";

String password="***";

String url="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=***";

Connection con=null;

try{

con=DriverManager.getConnection(url,user,password);

}catch(SQLException e)

{

e.printStackTrace();

}

return con;

}

public  String selectPassword(String username)

{

Connection connection=getConnection();

String sql="select *from login where username=";

PreparedStatement preparedStatement=null;

ResultSet result=null;

String password=null;

try{

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1,username);

result=preparedStatement.executeQuery();//可执行的     查询

if(result.next())

password=result.getString("password");

}catch(SQLException e){

e.printStackTrace();

}finally

{

close(preparedStatement);

close(result);

close(connection);

}

System.out.println("找到的数据库密码为:"+password);

return password;    

}

public  void close (Connection con)

{

try{

if(con!=null)

{

con.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public  void close (PreparedStatement preparedStatement)

{

try{

if(preparedStatement!=null)

{

preparedStatement.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public  void close(ResultSet resultSet)

{

try{

if(resultSet!=null)

{

resultSet.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

}

2、login_check.jsp:文件

<%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ";>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>验证用户密码</title>

</head>

<body>

<jsp:useBean id="util" class="util.Data_uil" scope="page" />

<%

String username=(String)request.getParameter("username");

String password=(String)request.getParameter("password");

if(username==null||"".equals(username))

{

out.print("<script language='javaScript'> alert('用户名不能为空');</script>");

response.setHeader("refresh", "0;url=user_login.jsp");

}

else

{

System.out.println("输入的用户名:"+username);

String passwordInDataBase=util.selectPassword(username);

System.out.println("密码:"+passwordInDataBase);

if(passwordInDataBase==null||"".equals(passwordInDataBase))

{

out.print("<script language='javaScript'> alert('用户名不存在');</script>");

response.setHeader("refresh", "0;url=user_login.jsp");

}

else if(passwordInDataBase.equals(password))

{

out.print("<script language='javaScript'> alert('登录成功');</script>");

response.setHeader("refresh", "0;url=loginSucces.jsp");

}

else

{

out.print("<script language='javaScript'> alert('密码错误');</script>");

response.setHeader("refresh", "0;url=user_login.jsp");

}

}

%>

</body>

</html>

3、loginSucces.jsp文件

<%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ";>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

<hr size="10" width="26%" align="left" color="green">

<font size="6" color="red" >登录成功 </font>

<hr size="10" width="26%" align="left" color="green">

</body>

</html>

4、user_login.jsp文件

<%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ";>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>登录界面</title>

</head>

<body  background="C:Userswin8workspaceLoginimage9dcbdc339e72a5663b5c289fb5573c13_10.jpg" >

<center>

<br><br><br><br><br><br>

<h1 style="color:yellow">Login</h1>

<br>

<form name="loginForm" action="login_check.jsp" method="post">   

<table Border="0" >

<tr >

<td>账号</td>

<td><input type="text" name="username"></td>

</tr>

<tr>

<td>密码</td>

<td><input type="password" name="password">

</td>

</tr>

</table>

<br>

<input type="submit" value="登录" style="color:#BC8F8F">

</form>

</center>

</body>

</html>

以上就是重庆云诚科技小编解答贡献者:(秋水潺潺)回答的关于“jsp登陆界面源代码”的问题了,不知是否已经解决你的问题?如果没有,下一篇内容可能是你想要的答案,下面继续浅析下文用户【空城旧梦】分析的“用vf设计登录页面”的一些相关问题做出分析与解答,如果能找到你的答案,可以关注本站。

jsp登陆界面源代码

用vf设计登录页面

本文贡献者:【空城旧梦】, 疑问关键字:web登录页面设计, 下面就让重庆云诚科技小编为你解答,希望本文能找到您要的答案!

首先要有一个表

tabid.dbf

用于存放用户名和密码,至少有“用户名”和“密码”两个字段。

设计一个登录表单,至少有两个文本框分别为text1

(用于填写用户名)和text2(用于填写密码)。至少有二个命令按钮command1(确定)和command2(取消)

再有,本人习惯添加一个标签控件

label1,并设其

Caption

初始值为“0”

command1的代码如下

*设置用户名不能为空,如允许为空则不需此步骤

If

Len(Alltrim(Thisform.text1.Value))=0

Messagebox('请输入用户名!')

Return

Endif

*设置密码不能为空,如允许为空则不需此步骤

If

Len(Alltrim(Thisform.text2.Value))=0

Messagebox('请输入密码!')

Return

Endif

Use

tabid.Dbf

In

0

Locate

For

Alltrim(用户名)==Alltrim(Thisform.text1.Value)

&&定位到与输入用户名相同的记录

*如果没有找到相同记录时执行下面代码

If

Eof()

Use

Messagebox('没有此用户!')

Thisform.text1.Value=''

Thisform.text2.Value=''

Thisform.text1.SetFocus

Thisform.label1.Caption=Alltrim(Str(Val(Thisform.label1.Caption)+1))

&&累计出错的次数

If

Thisform.label1.Caption='3'

&&出错三次后自动退出

Messagebox('连续三次输入错误,系统将退出!')

Use

Quit

Endif

Return

ENDIF

*找到后执行的动做

If

Alltrim(Thisform.text2.Value)==Alltrim(密码)

Use

在这里添加在正确登录后你要继续执行的程度

Else

Use

Messagebox('密码错误!')

Thisform.text2.Value=''

Thisform.text2.SetFocus

Thisform.label1.Caption=Alltrim(Str(Val(Thisform.label1.Caption)+1))

If

Thisform.label1.Caption='3'

&&出错三次后自动退出

Messagebox('连续三次输入错误,系统将退出!')

Use

Quit

Endif

Return

ENDIF

没做测试。为使代码在帖子里美观,句首加入了全角空格,所以不能直接复制代码。请高手指正!

以上就是重庆云诚科技小编解答贡献者:(空城旧梦)解答的关于“用vf设计登录页面”的问题了,不知是否已经解决你的问题?如果没有,下一篇内容可能是你想要的答案,现在接着继续教您下文用户【剑神】回答的“html网页设计:一个简单的登录界面代码!”的一些相关问题做出分析与解答,如果能找到你的答案,可以关注本站。

html网页设计:一个简单的登录界面代码!

本文贡献者:【剑神】, 疑问关键字:web登录页面设计, 下面就让重庆云诚科技小编为你解答,希望本文能找到您要的答案!

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<link href="main.css" type="text/css" rel="stylesheet">

<title>登陆界面</title>

</head>

<body>

<div class="login_ico">

<img src="images/login_ico.png">

</div>

<div class="login_putin">

<ul>

<li><input type="text" ></li>

<li><input type="password" ></li>

</ul>

</div>

<div class="login_btn">

<input type="submit" value="登陆">

</div>

</body>

</html>

样式 :

*{

margin:0;

padding:0;}

li{

list-style-type:none;

margin:0;

padding:0;}

a{

text-decoration:none;

color:#000;}

/*---------------------按钮-----------------------------*/

.login_putin ul li input{

margin: 0;

width:70%;

padding: 1em 2em 1em 5.4em;

-webkit-border-radius:.3em;

-moz-border-radius: .3em;

border: 1px solid #999;

}

.login_btn{

width:300px;

margin:40px auto 0 auto;

}

.login_btn input{

width:100%;

margin:0;

padding:.5em 0;

-webkit-border-radius:.3em;

-moz-border-radius: .3em;

border:#1263be solid 1px;

background:#1b85fd;

color:#FFF;

font-size:17px;

font-weight:bolder;

letter-spacing:1em;

}

.login_btn input:hover{

background:#1263be;

}

上文就是重庆云诚科技小编分享贡献者:(剑神)解答的关于“html网页设计:一个简单的登录界面代码!”的问题了,不知是否已经解决你的问题?如果没有,下一篇内容可能是你想要的答案,下面继续讨论下文用户【孔雀南飞ヨ】分析的“用Java设计一个登录页面,不用连接数据库,只要把用户和密码信息存放在文本里面,怎样设计代码?”的一些相关疑问做出分析与解答,如果能找到你的答案,可以关注本站。

用Java设计一个登录页面,不用连接数据库,只要把用户和密码信息存放在文本里面,怎样设计代码?

本文贡献者:【孔雀南飞ヨ】, 疑问关键字:web登录页面设计, 下面就让重庆云诚科技小编为你解答,希望本文能找到您要的答案!

/* Main.java

*

* Created on __DATE__, __TIME__

*/

import javax.swing.JOptionPane;

/**

*

* @author __USER__

*/

public class Main extends javax.swing.JFrame {

/** Creates new form Main */

public Main() {

initComponents();

}

/** This method is called from within the constructor to

* initialize the form.

* WARNING: Do NOT modify this code. The content of this method is

* always regenerated by the Form Editor.

*/

//GEN-BEGIN:initComponents

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jPanel1 = new javax.swing.JPanel(); //标签

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

jButton1 = new javax.swing.JButton(); //登录按钮

jButton2 = new javax.swing.JButton(); //

jTextField1 = new javax.swing.JTextField(); //文本框

jTextField2 = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); //关闭时的操作,即退出程序

setTitle("登录界面"); //设置标题:欢迎使用股票管理系统

setResizable(false); //设置窗口不可调节大小

jLabel1.setFont(new java.awt.Font("微软雅黑", 0, 18)); //设置标签的字体

jLabel1

.setText("您好,请输入信息");

jLabel2.setText("用户名");

jLabel3.setText("用户密码");

jButton1.setText("登录");

jButton1.addActionListener(new java.awt.event.ActionListener() { //采用匿名内部类来实现按钮监听功能

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

}

});

jButton2.setText("退出");

jButton2.addActionListener(new java.awt.event.ActionListener() { //同上

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

}

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout( //层次布局管理器,下面n长的代码,就是设置位置,自己看吧,呵呵,这个必须的,就不多写了

jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout

.setHorizontalGroup(jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

javax.swing.GroupLayout.Alignment.TRAILING,

jPanel1Layout.createSequentialGroup()

.addContainerGap(159, Short.MAX_VALUE)

.addComponent(jLabel1).addGap(140, 140,

140))

.addGroup(

jPanel1Layout

.createSequentialGroup()

.addGap(110, 110, 110)

.addGroup(

jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel2)

.addComponent(jLabel3))

.addGap(54, 54, 54)

.addGroup(

jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

jPanel1Layout

.createSequentialGroup()

.addComponent(

jTextField2,

javax.swing.GroupLayout.DEFAULT_SIZE,

191,

Short.MAX_VALUE)

.addGap(

112,

112,

112))

.addGroup(

jPanel1Layout

.createSequentialGroup()

.addComponent(

jTextField1,

javax.swing.GroupLayout.PREFERRED_SIZE,

191,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap())))

.addGroup(

jPanel1Layout

.createSequentialGroup()

.addGap(141, 141, 141)

.addComponent(

jButton1,

javax.swing.GroupLayout.PREFERRED_SIZE,

68,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(89, 89, 89)

.addComponent(

jButton2,

javax.swing.GroupLayout.PREFERRED_SIZE,

72,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(145, Short.MAX_VALUE)));

jPanel1Layout

.setVerticalGroup(jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

jPanel1Layout

.createSequentialGroup()

.addContainerGap()

.addComponent(jLabel1)

.addGap(55, 55, 55)

.addGroup(

jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel2)

.addComponent(

jTextField1,

javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE,

javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(41, 41, 41)

.addGroup(

jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel3)

.addComponent(

jTextField2,

javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE,

javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(43, 43, 43)

.addGroup(

jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(

jButton1,

javax.swing.GroupLayout.PREFERRED_SIZE,

33,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(

jButton2,

javax.swing.GroupLayout.PREFERRED_SIZE,

33,

javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(48, Short.MAX_VALUE)));

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(

getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING).addGroup(

layout.createSequentialGroup().addContainerGap().addComponent(

jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap()));

layout.setVerticalGroup(layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING).addGroup(

layout.createSequentialGroup().addContainerGap().addComponent(

jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,

Short.MAX_VALUE)));

pack();

setLocationRelativeTo(null); //居中

}// </editor-fold>

//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { //事件处理,不建议这样做

// TODO add your handling code here:

String name = this.jTextField1.getText().trim(); //获得用户名,去空格

String password = this.jTextField2.getText().trim(); //获得密码,去空格

if (name.equals("admin") && password.equals("123456")) { //如果符合条件.其实这里应该去和数据库关联,这是死代码

// Showinformation sf=new Showinformation(); //我估计是另外一个框架,就是登录成功之后的框架

// sf.setVisible(true);

// sf.show(); //这个方法就直接秒杀,不用了,因为sf.setVisible(true)已经被调用了,这里就多次一举了

} else { //用户名或者密码验证失败

JOptionPane.showMessageDialog(this, "用户名或者密码错误啦~", "提示", //提示框

JOptionPane.INFORMATION_MESSAGE);

this.jTextField1.setText(""); //清空输入框

this.jTextField2.setText("");

}

}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { //事件处理,其实可以将jButton1ActionPerformed放在一起处理,只要获得按钮的标签内容 (JButton)(evt.getSuorse()).getText()就做对比就ko了

// TODO add your handling code here:

System.exit(0);

}

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() { //好方法,呵呵使用该方式的原因是:awt是单线程模式的,所有awt的组件只能在(推荐方式)事件处理线程中访问,从而保证组件状态的可确定性。java核心编程技术中每个实例基本都用到了

public void run() {

new Main().setVisible(true);

}

});

}

//GEN-BEGIN:variables

// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JPanel jPanel1;

private javax.swing.JTextField jTextField1;

private javax.swing.JTextField jTextField2;}

// End of variables declaration//GEN-END:variables

你修改一下吧,从记事本获得用户名判断一下就行了

关于[web登录页面设计]的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于登录页面设计代码、web登录页面设计的信息别忘了在本站进行查找喔。

推荐文章:

  • 管家婆一句赢钱料图
  • 两肖两码准
  • 今期香港挂挂牌生肖表
  • 小鱼儿特马站
  • 平心静气打一生肖数字
  • 马会传真2019特马
  • 管家婆三十码
  • 管家婆登陆官网
  • u7金牛版
  • 平特一尾什么意思
  • 本文由网上采集发布,不代表我们立场,转载联系作者并注明出处:https://www.cqycseo.com/kangadmin/makehtml_archives_action.php?endid=0&startid=-1&typeid=15&totalnum=6115&startdd=1260&pagesize=20&seltime=0&sstime=1679321406&stime=&etime=&uptype=&mkvalue=0&isremote=0&serviterm=

    联系我们

    在线咨询:点击这里给我发消息

    微信号:

    工作日:9:30-18:30,节假日休息