×

登录界面代码 jsp js

jsp登陆界面源代码?怎样在js里面格式化日期

admin admin 发表于2022-06-03 17:57:10 浏览107 评论0

抢沙发发表评论

jsp登陆界面源代码


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“ “http://www.w3.org/TR/html4/loose.dtd“》-jsp

《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“ “http://www.w3.org/TR/html4/loose.dtd“》-jsp

《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“ “http://www.w3.org/TR/html4/loose.dtd“》-jsp

《html》

《head》

《meta http-equiv=“Content-Type“ content=“text/html; charset=ISO-8859-1“》

《title》登录界面《/title》

《/head》

《body  background=“C:\Users\win8\workspace\Login\image\9dcbdc339e72a5663b5c289fb5573c13_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》


怎样在js里面格式化日期


格式化时间
参数: formatStr 格式化串 y年,m月,d日,h小时,i分钟,s秒钟  缺省值 “y-m-d h:i:s“
fdate 要格式化的时间(时间戳)UTC秒数 缺省值 当前时间
实例: formatDate()  当前时间默认格式 如 2011-4-12 12:51:12
formatDate(’y/m/d’, 2132132131) 某时间格式为 年月日 如 2010/12/5  
function formatDate(formatStr, fdate)
{
var fTime, fStr = ’ymdhis’;
if (!formatStr)
formatStr= “y-m-d h:i:s“;
if (fdate)
fTime = new Date(fdate);
else
fTime = new Date();
var formatArr = [
fTime.getFullYear().toString(),
(fTime.getMonth()+1).toString(),
fTime.getDate().toString(),
fTime.getHours().toString(),
fTime.getMinutes().toString(),
fTime.getSeconds().toString()
]
for (var i=0; i《formatArr.length; i++)
{
formatStr = formatStr.replace(fStr.charAt(i), formatArr[i]);
}
return formatStr;
}
-js

  • 步骤一:将日期转换成我们常用的“yyyy-MM-dd hh:mm:ss”这种格式,我们可以对日期进行获取然后组装,具体代码如下所示:

  • 步骤二:将日期转换成“某年某月某日”这种日期格式,此时我们只需要调用Date类的toLocaleDateString方法即可。

  • 步骤三:直接获取“hh:mm:ss”时间,此时我们只需要调用Date的toLocaleTimeString方法即可。

  • 步骤四:获取“获取“某年某月某日 hh:mm:ss“”这种格式,我们需要调用Date类的toLocaleString方法。

  • 步骤五:调用dateFormat()方法。

  • 6

    步骤六:测试。启动项目后,浏览器中输入

参考资料

百度经验.搜狗[引用时间2018-5-3]


如何使用Lightbox 2


  Lightbox JS 是一个简单而又谦恭的用来把图片覆盖在当前页面上的脚本. 它能被快速安装并且运作于所有流行的浏览器.
  使用方法如下:
  步骤 1 - 安装

  1、Lightbox v2.0 使用 Prototype 框架和 Scriptaculous 效果库. 将需要外调这三个 Javascript 文件在的 header.

  《script type=“text/javascript“ src=“js/prototype.js“》《/script》
  《script type=“text/javascript“ src=“js/scriptaculous.js?load=effects“》《/script》
  《script type=“text/javascript“ src=“js/lightbox.js“》《/script》

  2、外调 Lightbox CSS 文件 (或添加 Lightbox 样式到现行的样式表中).

  《link rel=“stylesheet“ href=“css/lightbox.css“ type=“text/css“ media=“screen“ /》
  3、检查 CSS 并确定调用的 prev.gif 和 next.gif 文件在正确的位置. 同样要确定调用的 loading.gif 和 close.gif 文件及 lightbox.js 文件在正确的位置.

  步骤 2 - 激活

  1、添加 rel=“lightbox“ 属性到任何一个链接标签去激活lightbox. 例如:

  《a href=“images/image-1.jpg“ rel=“lightbox“ title=“my caption“》image #1《/a》

  可选择项: 使用 title 属性加上说明.

  2、如果有一套想分组的相关图片, 接着上一部并且又在 rel 属性中添加一个带方括号的组名. 例如:

  《a href=“images/image-1.jpg“ rel=“lightbox[roadtrip]“》image #1《/a》
  《a href=“images/image-2.jpg“ rel=“lightbox[roadtrip]“》image #2《/a》
  《a href=“images/image-3.jpg“ rel=“lightbox[roadtrip]“》image #3《/a》
  3、没有限定每个页面的图片组数量和每个图片组图片的数量。
-jsp