新手新教 关于JSP页面刷新不闪烁的问题 多谢!
大家好!请问怎样实现JSP页面刷新时,屏幕不闪烁?
多谢!!
<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
jsp1
</title>
</head>
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
</h1>
<%
String str=request.getParameter("sel");
System.out.println(request.getParameter("a"));
//String str[][]=new String[1][1];
//for(int i=0;i<1;i++){
// for(int j=0;j<1;j++){
// str[i][j]=i+""+j;
// }
//}
//application.setAttribute("str",str);
//String result[][]=new String[1][1];
//result=(String[][])application.getAttribute("str");
//for(int i=0;i<1;i++){
// for(int j=0;j<1;j++){
// System.out.println(result[i][j]);
// }
//}
%>
<form action="jsp1.jsp">
<select name="sel">
<option value="a" selected><img src="F:\我的文档\photo\p582.gif">
<option value="b">bb
<option value="c">cc
</select>
<input type="checkbox" name="a" value="a">a
<input type="checkbox" name="a" value="b">b
<input type="checkbox" name="a" value="c">c
<input type="checkbox" name="a" value="d">d
<input type="submit"/>
<input type="file" name="abc">
<input type="button" value="Ajax第一个程序" onClick="qingqiu();"/>
</form>
<script>
<%if(str!=null){%>
document.all("sel").value="<%=str%>";
<%}%>
</script>
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20">
<a href="javascript:void(0)" onClick="showRoles('pos_1')">经理室</a>
</td>
</tr>
<tr style="display:none">
<td height="20" id="pos_1"> </td>
</tr>
<tr>
<td height="20">
<a href="javascript:void(0)" onClick="showRoles('pos_2')">开发部</a>
</td>
</tr>
<tr style="display:none">
<td id="pos_2" height="20"> </td>
</tr>
</table>
<script>
function showRoles(obj){
document.getElementById(obj).parentNode.style.display="";
document.getElementById(obj).innerHTML="数据正在读取中...";
currentPos=obj;
send_request("smaple2_2.jsp?playPos="+obj,true);
}
//定义XMLHttpRequest对象
var http_request=false;
function send_request(url,flag){
http_request=false;
//开始初始化XMLHttpRequest对象
if(window.XMLHttpRequest){//Mozilla等浏览器初始化XMLHttpRequest过程
http_request=new XMLHttpRequest();
//有些版本的Mozilla浏览器处理服务器返回的未包含XML mime-type头部信息的内容时会出错.
//因此,要确保返回的内容包含text/xml信息.
if(http_request.overrideMimeType){
http_request.overrideMimeType("text/xml");
}
}
else if(window.ActiveXObject){//IE浏览器初始化XMLHttpRequest过程
try{
http_request=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{
http_request=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){}
}
}
//异常,创建对象失败
if(!http_request){
window.alert("不能创建XMLHttpRequest对象实例!");
return false;
}
//指定响应处理函数
http_request.onreadystatechange=processRequest;
//发送HTTP请求信息
http_request.open("GET",url,true);
http_request.send(null);
if(flag){
flag=false;
haha();
}
}
//处理返回信息函数
function processRequest(){
//判断对象状态
if(http_request.readyState==4){
//判断HTTP状态码
if(http_request.status==200){
//信息已经成功返回
//window.document.write(http_request.responseText);
//alert(http_request.responseText);
document.getElementById(currentPos).innerHTML=http_request.responseText;
}
else {
//请求页面有问题
alert("您所请求的页面有异常!错误状态:"+http_request.status);
}
}
}
function qingqiu(){
alert(document.all("abc").value);
send_request("asdasd.jsp?a=a&b=b",true);
}
function haha(){
send_request("testsubmit.jsp",false);
}
</script>
</body>
</html>