一般在網(wǎng)上有免費(fèi)的界面提供下載,有一定的html,css,腳本方面的知識(shí),即使不懂,也能自我修改達(dá)到你要求的效果 算了我直接給你代碼得了
創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),任丘企業(yè)網(wǎng)站建設(shè),任丘品牌網(wǎng)站建設(shè),網(wǎng)站定制,任丘網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,任丘網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
*************************************test.html*********************************************************
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312" /
title3列固定寬度居中+頭部+尾部——a href=""標(biāo)準(zhǔn)之路;/a/title
link href="layout.css" rel="stylesheet" type="text/css" /
/head
body
div id="container"
div id="header"This is the Header/div
div id="mainContent"
div id="sidebar"This is the sidebar/div
div id="sidebar2"This is the sidebar2/div
div id="content"3列固定寬度居中+頭部+尾部——a href=""標(biāo)準(zhǔn)之路;/a/div
/div
div id="footer"This is the footer/div
/div
/body
/html
********************************************layout.css *************************************************
body { font-family:Verdana; font-size:14px; margin:0;}
#container {margin:0 auto; width:900px;}
#header { height:100px; background:#6cf; margin-bottom:5px;}
#mainContent { height:500px; margin-bottom:5px;}
#sidebar { float:left; width:200px; height:500px; background:#9ff;}
#sidebar2 { float:right; width:200px; height:500px; background:#9ff;}
#content { margin:0 205px !important; margin:0 202px; height:500px; background:#cff;}
#footer { height:60px; background:#6cf;}
用MyEclipse新建WEB項(xiàng)目,跟你新建java項(xiàng)目是同一級(jí)別目錄下的。要寫網(wǎng)頁(yè)就是JSP了,JSP開發(fā)你要學(xué)會(huì)servlet和jsp,這是最起碼的,servlet就是java代碼了,jsp類似于html。
第一步:創(chuàng)建一個(gè)查詢過程,因?yàn)樵诘卿洉r(shí)要根據(jù)用戶名查詢用戶密碼
此步要用到pl/sql編程知識(shí),代碼如下:
create or replace procedure sel_user(uname in varchar2,pass out varchar2) is
begin
select users.password into pass from users where users.username=uname and rownum = 1;
end;
第二步:編寫登錄頁(yè)面(login.java)(采用純java+servlet編寫)
//login.java如下
package cn.hnu;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class testhtml extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/html;charset=gbk");
try {
PrintWriter pw = resp.getWriter();
pw.println("html");
pw.println("head");
pw.println("title");
pw.println("用戶登錄");
pw.println("/title");
pw.println("/head");
pw.println("body");
pw.println("h1用戶登錄/h1");
pw.println("hr");
pw.println("form method=post action=loginCl");
pw.println("用戶名:input type=text name=userNamebr");
pw.println("密nbspnbsp碼:input type=password name=passwordbr");
pw.println("input type=submit value=登錄");
pw.println("input type=reset value=重置");
pw.println("/form");
pw.println("/body");
pw.println("/html");
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
this.doGet(req, resp);
}
}
第三步:編程成功登錄頁(yè)面(wel.java) //wel.java如下,它主要用于用戶正常登錄后顯示信息給用戶
package cn.hnu;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class Wel extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
//防止用戶非法登錄
HttpSession hs = req.getSession();
String s = (String)hs.getAttribute("pass");
if(s == null){
resp.sendRedirect("login");
}
PrintWriter pw = resp.getWriter();
pw.write("welcome,hello");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
this.doGet(req, resp);
}
}
第四步:編寫login處理頁(yè)面(loginCl.java)
package cn.hnu;
import java.io.IOException;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class loginCl extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
String u = req.getParameter("userName");
String p = req.getParameter("password");
//查詢數(shù)據(jù)庫(kù)
String pa=null;
Connection ct = null;
CallableStatement cs = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
ct = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:oracle",
"scott", "tiger");
cs = ct.prepareCall("{call sel_user(?,?)}");
cs.setString(1, u);
cs.registerOutParameter(2, oracle.jdbc.OracleTypes.VARCHAR);
cs.execute();
pa = cs.getString(2);
System.out.println("u=" + u + " p=" + pa);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (cs != null) {
cs.close();
}
if (ct != null) {
ct.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//驗(yàn)證用戶信息是否合法
if (p.equals(pa)) {
HttpSession hs = req.getSession(true);//防止用戶非法登錄
hs.setAttribute("pass", "OK");
resp.sendRedirect("wel");
} else {
resp.sendRedirect("login");
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
this.doGet(req, resp);
}
}
親,sql可以換成MySQL
這個(gè)沒關(guān)系的,別的都可以照搬來用
代碼:
package FrameText;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FrameDemo extends JFrame {
JButton jbtwo ,jbHello, jbBye;
public FrameDemo() {
setLayout(new GridLayout(3, 1));// 3行1列布局
JPanel jp1 = new JPanel();// 第一行
JButton jb1 = new JButton("第一個(gè)按鈕");
JButton jb2 = new JButton("第二個(gè)按鈕");
JButton jb3 = new JButton("第三個(gè)按鈕");
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
add(jp1);
JPanel jp2 = new JPanel();// 第二行
JButton jbtwo = new JButton("第四個(gè)按鈕");
jp2.add(jbtwo);
add(jp2);
JPanel jp3 = new JPanel();// 第三行
jbHello = new JButton("第五個(gè)按鈕");
jbBye = new JButton("第六個(gè)按鈕");
jp3.add(jbHello);
jp3.add(jbBye);
add(jp3);
setSize(380, 180);
setTitle("窗口");
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
//點(diǎn)擊按鈕后響應(yīng)
public static void main(String[] args) {
new FrameDemo();
}
}
網(wǎng)頁(yè)地址在代碼中的java代碼寫法如下:
packagecom.test;
importjava.lang.reflect.Method;
//實(shí)現(xiàn)打開瀏覽器并跳到指定網(wǎng)址的類
publicclassBareBonesBrowserLaunch{
publicstaticvoidopenURL(Stringurl){
try{
browse(url);
}catch(Exceptione){
}
}
privatestaticvoidbrowse(Stringurl)throwsException{
//獲取操作系統(tǒng)的名字
StringosName=System.getProperty("os.name","");
if(osName.startsWith("MacOS")){
//蘋果的打開方式
ClassfileMgr=Class.forName("com.apple.eio.FileManager");
MethodopenURL=fileMgr.getDeclaredMethod("openURL",newClass[]{String.class});
openURL.invoke(null,newObject[]{url});
}elseif(osName.startsWith("Windows")){
//windows的打開方式。
Runtime.getRuntime().exec("rundll32url.dll,FileProtocolHandler"+url);
}else{
//UnixorLinux的打開方式
String[]browsers={"firefox","opera","konqueror","epiphany","mozilla","netscape"};
Stringbrowser=null;
for(intcount=0;countbrowsers.lengthbrowser==null;count++)
//執(zhí)行代碼,在brower有值后跳出,
//這里是如果進(jìn)程創(chuàng)建成功了,==0是表示正常結(jié)束。
if(Runtime.getRuntime().exec(newString[]{"which",browsers[count]}).waitFor()==0)
browser=browsers[count];
if(browser==null)
thrownewException("Couldnotfindwebbrowser");
else
//這個(gè)值在上面已經(jīng)成功的得到了一個(gè)進(jìn)程。
Runtime.getRuntime().exec(newString[]{browser,url});
}
}
}
//主方法測(cè)試類
publicstaticvoidmain(String[]args){
Stringurl="";
BareBonesBrowserLaunch.openURL(url);
}
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,"用戶名或密碼錯(cuò)誤!");
} 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);
}
}
網(wǎng)頁(yè)標(biāo)題:java用代碼編寫頁(yè)面 jsp頁(yè)面寫java代碼
轉(zhuǎn)載源于:http://aaarwkj.com/article20/dooocjo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣、移動(dòng)網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站改版、App設(shè)計(jì)、小程序開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)