XML的web网页期末课设Word文件下载.docx

上传人:b****8 文档编号:22233026 上传时间:2023-02-03 格式:DOCX 页数:17 大小:322.19KB
下载 相关 举报
XML的web网页期末课设Word文件下载.docx_第1页
第1页 / 共17页
XML的web网页期末课设Word文件下载.docx_第2页
第2页 / 共17页
XML的web网页期末课设Word文件下载.docx_第3页
第3页 / 共17页
XML的web网页期末课设Word文件下载.docx_第4页
第4页 / 共17页
XML的web网页期末课设Word文件下载.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

XML的web网页期末课设Word文件下载.docx

《XML的web网页期末课设Word文件下载.docx》由会员分享,可在线阅读,更多相关《XML的web网页期末课设Word文件下载.docx(17页珍藏版)》请在冰豆网上搜索。

XML的web网页期末课设Word文件下载.docx

privatebooleanexistsUsername(Stringusername){

ResultSetresult=null;

try{

Statementselect=RequestSQL.getConnection().createStatement();

result=select.executeQuery("

SELECTnamefromUSERSwherename='

"

+username+"

'

;

);

if(result==null||result.next()){returntrue;

}

}

catch(SQLExceptione){

e.printStackTrace();

returnfalse;

通过register-ajax.js中的callback()函数取得servlet结果并加以验证后返回结果到客户端(以id值相关联):

functioncallback()

{

if(request.readyState==4){

if(request.status==200)

if(request.responseText=="

true"

{

alert("

用户名已存在"

document.getElementById("

name"

).value="

}else{

varmessage="

ok"

nametext"

).innerHTML=message;

四、注册信息确认页面自动显示密码:

定义StringBuffer型的对象

以XML的格式存储数据:

在JS中以DOM解析的方式解析XML并返回前台:

信息确认密码显示效果展示:

五、登陆界面建议区展示:

利用%搜索数据库,ajax异步传输,悬浮框展示的技术实现建议区。

密码验证截图:

与信息确认页面以相同的方法进行ajax请求、查询数据库,验证用户名和密码是否匹配,如果不匹配,返回错误信息,若匹配则跳转到首页。

if(result.next()){

result.first();

HttpSessionsession=request.getSession(true);

session.setAttribute("

name);

response.sendRedirect("

index.html"

else{

out.print("

<

script>

alert('

用户名或密码不正确!

window.location.href='

login.html'

/script>

搜索关键字rice,返回它的其他信息:

1、导入自定义标签映射文件并赋值:

%@tagliburi="

/tlds/selectajax.tld"

prefix="

selectajax"

%>

selectajax:

selectnameId="

priceId="

price"

caixiId="

caixi"

discribeId="

discribe"

url="

select"

/>

2、标签库文档代码:

?

xmlversion="

1.0"

encoding="

UTF-8"

>

taglibversion="

2.1"

xmlns="

xmlns:

xsi="

http:

//www.w3.org/2001/XMLSchema-instance"

xsi:

schemaLocation="

<

tlib-version>

1.0<

/tlib-version>

short-name>

selectajax<

/short-name>

uri>

/tlds/selectajax<

/uri>

tag>

name>

select<

/name>

tagclass>

ex.selectTag<

/tagclass>

bodycontent>

empty<

/bodycontent>

attribute>

nameId<

required>

true<

/required>

/attribute>

priceId<

caixiId<

discribeId<

url<

rtexprvalue>

/rtexprvalue>

description>

theurloftheservletthathandlestherequestforselect

/description>

/tag>

/taglib>

3、标签库处理程序代码:

publicclassselectTagextendsTagSupport{

privateStringnameId="

0"

privateStringpriceId="

privateStringcaixiId="

privateStringdiscribeId="

privateStringurl="

publicintdoStartTag(){

try{

this.pageContext.getOut().print(

JavaScriptCode.getselectScript(priceId,caixiId,discribeId,nameId,

url));

catch(IOExceptione){

System.out.println("

couldn'

twriteJavaScripttojsp"

+e.getMessage());

returnSKIP_BODY;

publicStringgetpriceId(){

returnpriceId;

publicvoidsetpriceId(Stringprice){

this.priceId=price;

publicStringgetcaixiId(){

returncaixiId;

publicvoidsetcaixiId(Stringcaixi){

this.caixiId=caixi;

publicStringgetdiscribeId(){

returndiscribeId;

publicvoidsetdiscribeId(Stringdiscribe){

this.discribeId=discribe;

publicStringgetUrl(){

returnurl;

publicvoidsetUrl(Stringurl){

this.url=url;

publicStringgetnameId(){

returnnameId;

publicvoidsetnameId(StringnameId){

this.nameId=nameId;

}}

3、以JSON对象的多值包装:

publicclassJavaScriptCode{

publicstaticStringgetselectScript(StringpriceId,StringcaixiId,StringdiscribeId,StringnameId,

Stringurl){

StringBuffersb=newStringBuffer();

sb.append("

"

functionretrieveselect(){"

varurl='

+url+"

name='

+document.getElementById('

+nameId+"

).value;

if(window.XMLHttpRequest){"

req=newXMLHttpRequest();

}"

);

elseif(window.ActiveXObject){"

req=newActiveXObject('

Microsoft.XMLHTTP'

req.open('

Get'

url,true);

req.onreadystatechange=callbackselect;

req.send(null);

}"

functionpopulateselect(){"

varjsonData=req.responseText;

varmyJSONObject=eval('

('

+jsonData+'

)'

rname.innerHTML=document.getElementById('

varprice=document.getElementById('

+priceId+"

price.innerHTML=myJSONObject.location.price;

varcaixi=document.getElementById('

+caixiId+"

caixi.innerHTML=myJSONObject.location.caixi;

vardiscribe=document.getElementById('

+discribeId+"

discribe.innerHTML=myJSONObject.location.discribe;

functioncallbackselect(){"

if(req.readyState==4){"

if(req.status==200){"

populateselect();

}"

returnsb.toString();

}

七、小结:

在这次阶段性实习2中,大概了解到了一个网站建设的大致流程,并且感受到了XML传值的妙处,并了解了不同的XML解析方式。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 电力水利

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1