-
當(dāng)前位置:首頁 > 創(chuàng)意學(xué)院 > 技術(shù) > 專題列表 > 正文
javaweb漂亮的登錄界面源碼(java web登錄界面代碼)
大家好!今天讓創(chuàng)意嶺的小編來大家介紹下關(guān)于javaweb漂亮的登錄界面源碼的問題,以下是小編對此問題的歸納整理,讓我們一起來看看吧。
開始之前先推薦一個非常厲害的Ai人工智能工具,一鍵生成原創(chuàng)文章、方案、文案、工作計劃、工作報告、論文、代碼、作文、做題和對話答疑等等
只需要輸入關(guān)鍵詞,就能返回你想要的內(nèi)容,越精準(zhǔn),寫出的就越詳細(xì),有微信小程序端、在線網(wǎng)頁版、PC客戶端
官網(wǎng):https://ai.de1919.com。
創(chuàng)意嶺作為行業(yè)內(nèi)優(yōu)秀的企業(yè),服務(wù)客戶遍布全球各地,如需了解SEO相關(guān)業(yè)務(wù)請撥打電話175-8598-2043,或添加微信:1454722008
本文目錄:
一、用java怎樣編寫登錄頁面,成功登錄跳轉(zhuǎn)到下一個頁面,求代碼
說說servlet里面的方法:
public void ValidateUserPass(String user,String pass){
RequestDispathcher rd =null
//假使你的代碼是從DB中獲取DBFactory db=DBFactoryImpl.getDBFactoryInstance();//得到數(shù)據(jù)庫鏈接
flg=db.findUser(user,pass);
// 這里是不存在用戶
if(flg.hasNext()==-1){
// 登錄時錯誤了,一般我們會給用戶一個提示
session.setAttirbute("msg","對不起,用戶名或密碼錯誤");
RequestDispathcher rd = req.getRequesDispatcher("login.jsp");
rd.forward(request, reponse);//將請求對象和響應(yīng)對象傳遞進(jìn)來
} // 這里是存在當(dāng)前用戶
else{
//當(dāng)然這里登錄成功時,我們要把當(dāng)前用戶寫到session里面保存
session.setAttirbute("userName",user);
//這個請求轉(zhuǎn)發(fā)語句
request.sendRedirect("index.html");
}
}
// * 上述代碼,你可以參考下我的方法,我也很久沒做JAVA開發(fā)了,我現(xiàn)在從事前端UI開發(fā),本來我想在寫一個用struts 2登錄的程序的,可我現(xiàn)在忘得差不多了,上面我所用到的屬性建議你自己好好的研究一下,往后你將學(xué)到struts2 hibernate,Spring等一系列優(yōu)秀的開源框架,說白了,這些東西的底層還是這些,只不過這些框架做了一些封裝隔離。上述代碼建議你重點理解一下:請求轉(zhuǎn)發(fā)和重定向的區(qū)別。
二、用java web編寫一個用戶注冊界面(只要寫出以下要求就行)
一步步更新:頁面
<form action="regist.servlet" method="post"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" class="tableAdd borTop"> <tr> <th width="14%" height="30" nowrap>用戶名</th> <td class="pl5"> <INPUT id="sName" name="name" type="text" size="20"> </td> </tr> <tr> <th width="14%" height="30" nowrap>密碼</th> <td class="pl5"> <INPUT name="password" type="password" size="20"> </td> </tr> <tr> <th width="14%" height="30" nowrap>確認(rèn)密碼</th> <td class="pl5"> <INPUT name="confrimPwd" type="password" size="20"> </td> </tr> <tr> <th width="14%" height="30" nowrap>性別</th> <td class="pl5"> 男<INPUT name="sex" type="radio" value="1" checked="checked" size="20"> 女<INPUT name="sex" type="radio" value="0" size="20"> </td> </tr> <tr> <th width="14%" height="30" nowrap>愛好</th> <td class="pl5"> <INPUT name="enjoy" type="checkbox" size="20" value="籃球">籃球 <INPUT name="enjoy" type="checkbox" size="20" value="足球">足球 </td> </tr> <tr> <th width="14%" height="30" nowrap>生日</th> <td class="pl5"> <INPUT name="brithday" type="text" size="20"> </td> </tr> <tr> <th width="14%" height="30" nowrap>備注</th> <td class="pl5"> <textarea rows="5" cols="200" name="remark"></textarea> </td> </tr> <tr> <th width="14%" height="30" nowrap> </th> <td class="pl5"> <input type="submit" value="提交"> <input type="reset" value="重置"> </td> </tr></table></form>
數(shù)據(jù)庫部分:
import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import com.mysql.jdbc.Connection;import com.mysql.jdbc.Statement;public class DataBaseUtil { public static Connection getConnection() throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://192.168.100.113/datebase", "username", "password"); return conn; } public static Statement getPS() throws ClassNotFoundException, SQLException { Statement statement = (Statement) getConnection().createStatement(); return statement; } public static void close(Connection conn,Statement st,ResultSet rs) throws SQLException{ if(rs != null) { rs.close(); } if(st != null) { st.close(); } if(conn != null) { conn.close(); } }}
三、求一套完整的JAVA WEB項目的網(wǎng)絡(luò)購物網(wǎng)站源代碼
/*** @description:
* @author chenshiqiang E-mail:csqwyyx@163.com
* @date 2014年9月7日 下午2:51:50
* @version 1.0
*/
package com.example.baidumap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.PagerTabStrip;
import android.support.v4.view.ViewPager;
import android.text.Editable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ListView;
import com.baidu.mapapi.map.offline.MKOLSearchRecord;
import com.baidu.mapapi.map.offline.MKOLUpdateElement;
import com.baidu.mapapi.map.offline.MKOfflineMap;
import com.baidu.mapapi.map.offline.MKOfflineMapListener;
import com.example.baidumap.adapters.OfflineExpandableListAdapter;
import com.example.baidumap.adapters.OfflineMapAdapter;
import com.example.baidumap.adapters.OfflineMapManagerAdapter;
import com.example.baidumap.interfaces.OnOfflineItemStatusChangeListener;
import com.example.baidumap.models.OfflineMapItem;
import com.example.baidumap.utils.CsqBackgroundTask;
import com.example.baidumap.utils.ToastUtil;
import com.example.system.R;
public class BaiduOfflineMapActivity extends Activity implements MKOfflineMapListener, OnOfflineItemStatusChangeListener
{
// ------------------------ Constants ------------------------
// ------------------------- Fields --------------------------
private ViewPager viewpager;
private PagerTabStrip pagertab;
private MySearchView svDown;
private ListView lvDown;
private MySearchView svAll;
private ExpandableListView lvWholeCountry;
private ListView lvSearchResult;
private List<View> views = new ArrayList<View>(2);
private List<String> titles = new ArrayList<String>(2);
private MKOfflineMap mOffline = null;
private OfflineMapManagerAdapter downAdapter;
private OfflineMapAdapter allSearchAdapter;
private OfflineExpandableListAdapter allCountryAdapter;
private List<OfflineMapItem> itemsDown; // 下載或下載中城市
private List<OfflineMapItem> itemsAll; // 所有城市,與熱門城市及下載管理對象相同
private List<OfflineMapItem> itemsProvince;
private List<List<OfflineMapItem>> itemsProvinceCity;
// ----------------------- Constructors ----------------------
// -------- Methods for/from SuperClass/Interfaces -----------
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_offline_map);
// final String packname = this.getPackageName();
// PackageInfo packageInfo;
// try
// {
// packageInfo = this.getPackageManager().getPackageInfo(packname, PackageManager.GET_SIGNATURES);
//
//
// if (code == -00)
// {
// 初始化離線地圖管理
mOffline = new MKOfflineMap();
mOffline.init(this);
initViews();
viewpager.setCurrentItem(1);
// }
// }
// catch (NameNotFoundException e)
// {
// e.printStackTrace();
// }
}
private boolean isResumed = false;
@Override
protected void onResume()
{
super.onResume();
if (!isResumed)
{
isResumed = true;
loadData();
}
}
@Override
protected void onDestroy()
{
super.onDestroy();
mOffline.destroy();
}
/**
*
* @author chenshiqiang E-mail:csqwyyx@163.com
* @param type
* 事件類型: MKOfflineMap.TYPE_NEW_OFFLINE, MKOfflineMap.TYPE_DOWNLOAD_UPDATE, MKOfflineMap.TYPE_VER_UPDATE.
* @param state
* 事件狀態(tài): 當(dāng)type為TYPE_NEW_OFFLINE時,表示新安裝的離線地圖數(shù)目. 當(dāng)type為TYPE_DOWNLOAD_UPDATE時,表示更新的城市ID.
*/
@Override
public void onGetOfflineMapState(int type, int state)
{
switch (type)
{
case MKOfflineMap.TYPE_DOWNLOAD_UPDATE:
MKOLUpdateElement update = mOffline.getUpdateInfo(state);
if (setElement(update, true) != null)
{
if (itemsDown != null && itemsDown.size() > 1)
{
Collections.sort(itemsDown);
}
refreshDownList();
}
else
{
downAdapter.notifyDataSetChanged();
}
allSearchAdapter.notifyDataSetChanged();
allCountryAdapter.notifyDataSetChanged();
break;
case MKOfflineMap.TYPE_NEW_OFFLINE:
// 有新離線地圖安裝
Log.d("OfflineDemo", String.format("add offlinemap num:%d", state));
break;
case MKOfflineMap.TYPE_VER_UPDATE:
// 版本更新提示
break;
}
}
/**
* 百度下載狀態(tài)改變(暫停--》恢復(fù))居然不回調(diào),所以改變狀態(tài)時自己得增加接口監(jiān)聽狀態(tài)改變刷新界面
*
* @author chenshiqiang E-mail:csqwyyx@163.com
* @param item
* 有狀態(tài)改變的item
* @param removed
* item是否被刪除
*/
@Override
public void statusChanged(OfflineMapItem item, boolean removed)
{
if (removed)
{
for (int i = itemsDown.size() - 1; i >= 0; i--)
{
OfflineMapItem temp = itemsDown.get(i);
if (temp.getCityId() == item.getCityId())
{
itemsDown.remove(i);
}
}
refreshDownList();
}
else
{
loadData();
downAdapter.notifyDataSetChanged();
}
allSearchAdapter.notifyDataSetChanged();
allCountryAdapter.notifyDataSetChanged();
}
// --------------------- Methods public ----------------------
public void toDownloadPage()
{
viewpager.setCurrentItem(0);
}
// --------------------- Methods private ---------------------
private void initViews()
{
// TODO
viewpager = (ViewPager) findViewById(R.id.viewpager);
pagertab = (PagerTabStrip) findViewById(R.id.pagertab);
LayoutInflater inf = LayoutInflater.from(this);
View v1 = inf.inflate(R.layout.view_offline_download, null, false);
svDown = (MySearchView) v1.findViewById(R.id.svDown);
lvDown = (ListView) v1.findViewById(R.id.lvDown);
views.add(v1);
View v2 = inf.inflate(R.layout.view_offline_countrys, null, false);
svAll = (MySearchView) v2.findViewById(R.id.svAll);
lvWholeCountry = (ExpandableListView) v2.findViewById(R.id.lvWholeCountry);
lvSearchResult = (ListView) v2.findViewById(R.id.lvSearchResult);
views.add(v2);
titles.add("下載管理");
titles.add("城市列表");
pagertab.setTabIndicatorColor(0xff00cccc);
pagertab.setDrawFullUnderline(false);
pagertab.setBackgroundColor(0xFF38B0DE);
pagertab.setTextSpacing(50);
viewpager.setOffscreenPageLimit(2);
viewpager.setAdapter(new MyPagerAdapter());
svDown.setSearchListener(new MySearchView.SearchListener()
{
@Override
public void afterTextChanged(Editable text)
{
refreshDownList();
}
@Override
public void search(String text)
{
}
});
svAll.setSearchListener(new MySearchView.SearchListener()
{
@Override
public void afterTextChanged(Editable text)
{
refreshAllSearchList();
}
@Override
public void search(String text)
{
}
});
downAdapter = new OfflineMapManagerAdapter(this, mOffline, this);
lvDown.setAdapter(downAdapter);
allSearchAdapter = new OfflineMapAdapter(this, mOffline, this);
lvSearchResult.setAdapter(allSearchAdapter);
allCountryAdapter = new OfflineExpandableListAdapter(this, mOffline, this);
lvWholeCountry.setAdapter(allCountryAdapter);
lvWholeCountry.setGroupIndicator(null);
}
/**
* 刷新下載列表, 根據(jù)搜索關(guān)鍵字及itemsDown 下載管理數(shù)量變動時調(diào)用
*/
private void refreshDownList()
{
String key = svDown.getInputText();
if (key == null || key.length() < 1)
{
downAdapter.setDatas(itemsDown);
}
else
{
List<OfflineMapItem> filterList = new ArrayList<OfflineMapItem>();
if (itemsDown != null && !itemsDown.isEmpty())
{
for (OfflineMapItem i : itemsDown)
{
if (i.getCityName().contains(key))
{
filterList.add(i);
}
}
}
downAdapter.setDatas(filterList);
}
}
/**
* 刷新所有城市搜索結(jié)果
*/
private void refreshAllSearchList()
{
String key = svAll.getInputText();
if (key == null || key.length() < 1)
{
lvSearchResult.setVisibility(View.GONE);
lvWholeCountry.setVisibility(View.VISIBLE);
allSearchAdapter.setDatas(null);
}
else
{
lvSearchResult.setVisibility(View.VISIBLE);
lvWholeCountry.setVisibility(View.GONE);
List<OfflineMapItem> filterList = new ArrayList<OfflineMapItem>();
if (itemsAll != null && !itemsAll.isEmpty())
{
for (OfflineMapItem i : itemsAll)
{
if (i.getCityName().contains(key))
{
filterList.add(i);
}
}
}
allSearchAdapter.setDatas(filterList);
}
}
private void loadData()
{
new CsqBackgroundTask<Void>(this)
{
@Override
protected Void onRun()
{
// TODO Auto-generated method stub
// 導(dǎo)入離線地圖包
// 將從官網(wǎng)下載的離線包解壓,把vmp文件夾拷入SD卡根目錄下的BaiduMapSdk文件夾內(nèi)。
// 把網(wǎng)站上下載的文件解壓,將BaiduMapvmpl里面的.dat_svc文件,拷貝到手機(jī)BaiduMapSDK/vmp/h目錄下
int num = mOffline.importOfflineData();
if (num > 0)
{
ToastUtil.showToastInfo(BaiduOfflineMapActivity.this, "成功導(dǎo)入" + num + "個離線包", false);
}
List<MKOLSearchRecord> all = null;
try
{
all = mOffline.getOfflineCityList();
}
catch (Exception e)
{
e.printStackTrace();
}
if (all == null || all.isEmpty())
{
ToastUtil.showToastInfo(BaiduOfflineMapActivity.this, "未獲取到離線地圖城市數(shù)據(jù),可能有其他應(yīng)用正在使用百度離線地圖功能!", false);
return null;
}
List<MKOLSearchRecord> hotCity = mOffline.getHotCityList();
HashSet<Integer> hotCityIds = new HashSet<Integer>();
if (!hotCity.isEmpty())
{
for (MKOLSearchRecord r : hotCity)
{
hotCityIds.add(r.cityID);
}
}
itemsAll = new ArrayList<OfflineMapItem>();
itemsDown = new ArrayList<OfflineMapItem>();
itemsProvince = new ArrayList<OfflineMapItem>();
itemsProvinceCity = new ArrayList<List<OfflineMapItem>>();
// cityType 0:全國;1:省份;2:城市,如果是省份,可以通過childCities得到子城市列表
// 全國概略圖、直轄市、港澳 子城市列表
ArrayList<MKOLSearchRecord> childMunicipalities = new ArrayList<MKOLSearchRecord>();
proHot.cityName = "熱門城市";
proHot.childCities = cs;
List<MKOLUpdateElement> updates = mOffline.getAllUpdateInfo();
if (updates != null && updates.size() > 0)
{
}
@Override
protected void onResult(Void result)
{
// TODO Auto-generated method stub
refreshDownList();
refreshAllSearchList();
allCountryAdapter.setDatas(itemsProvince, itemsProvinceCity);
}
}.execute();
}
四、JAVA 網(wǎng)站源代碼
哈哈,這個我正好有,我自己做的網(wǎng)上商城,數(shù)據(jù)庫是MySQL,服務(wù)器是Tomcat,MyEclipse是開發(fā)工具,給你傳過去你看看吧。
以上就是關(guān)于javaweb漂亮的登錄界面源碼相關(guān)問題的回答。希望能幫到你,如有更多相關(guān)問題,您也可以聯(lián)系我們的客服進(jìn)行咨詢,客服也會為您講解更多精彩的知識和內(nèi)容。
推薦閱讀:
java,php,云計算運維,web前端,學(xué)哪個比較好?
用java開發(fā)微信小程序(用java開發(fā)微信小程序代碼)