JSP刷新问题
<%
if(userlogin.m_iNewPage == 1)
{
out.println( "dosomething() ");
userlogin.m_iNewPage = 0;
}
%>
我希望页面刷新的时候不插入dosomething()
但实际还是插入了dosomething()
有什么解决的办法?
------解决方案--------------------做完之后重定向页面
------解决方案--------------------没有听懂你的意思,你不需要不用就打出来就是了啊,给你看一个,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<HTML>
<HEAD>
<%@ page
language= "java "
contentType= "text/html; charset=GBK "
pageEncoding= "GBK "
%>
<META http-equiv= "Content-Type " content= "text/html; charset=GBK ">
<META name= "GENERATOR " content= "IBM WebSphere Studio ">
<META http-equiv= "Content-Style-Type " content= "text/css ">
<LINK href= "theme/Master.css " rel= "stylesheet " type= "text/css ">
<TITLE> 防刷新计数器 </TITLE>
</HEAD>
<BODY>
<%
int usercount=0;
Cookie thisCookie = null;
Cookie[] cookies = request.getCookies();
for (int i = 0; i < cookies.length; i++)
{
thisCookie = cookies[i];
if (thisCookie.getName().equals( "Count "))
{
usercount=Integer.parseInt(thisCookie.getValue());
if (session.isNew())
{
usercount++;
}
thisCookie.setValue(String.valueOf(usercount));
thisCookie.setMaxAge(100000);
response.addCookie(thisCookie);
break;
}
}
if (usercount==0)
{
usercount=1;
thisCookie = new Cookie( "Count ", "1 ");
thisCookie.setMaxAge(100000);
response.addCookie(thisCookie);
}
%>
单用户计数器 <br>
你是本站第 <%=usercount%> 个访问用户。
</BODY>
</HTML>