?? index.jsp
字號:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script>
//設一個變量
var XMLHttpReq=false;
//創建一個XMLHttpRequest對象
function createXMLHttpRequest(){
if(window.XMLHttpRequest){ //Mozilla
XMLHttpReq=new XMLHttpRequest();
}
else if(window.ActiveXObject){
try{
XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
}
//發送請求函數
function send(url){
createXMLHttpRequest();
XMLHttpReq.open("GET",url,true);
XMLHttpReq.onreadystatechange=proce; //指定響應的函數
XMLHttpReq.send(null); //發送請求
}
function proce(){
if(XMLHttpReq.readyState==4){ //對象狀態
if(XMLHttpReq.status==200){//信息已成功返回,開始處理信息
var res=XMLHttpReq.responseXML.getElementsByTagName("content")[0].firstChild.data;
window.alert(res);
}else{
window.alert("所請求的頁面有異常");
}
}
}
//身份驗證
function check(){
var name=document.getElementById("name").value;
if(name==""){
alert("請輸入姓名");
return false;
}
else{
send('login?name='+name);
}
}
</script>
</head>
<body>
<table>
<form action="login" method="post">
<tr><td>姓名: <input id="name" type="text" name="name"/><p>
<input type="button" value="檢測!" onClick="check()"/>
</td>
</tr>
</form>
</table>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -