你在页面中赋一个初值给Session。然后在页面中对session进行判断。如果她已经存在就不计数。
解决方案 »
- weblogic+myeclipse初学struts2部署时总是Could not load user defined filter in web.xml
- 求助,spring3 注解事务 回滚失败
- ireport做报表如何实现续打???
- jsp如果解析2次 “<%”
- tomcat启动错误
- 急问,用CXF做的web项目含一个webservice,Tomcat下可以运行,在Weblogic 下启动时报如下的错(在线等)
- 采用自动生成的主键有什么优缺点
- JSP报错,请教如何配置
- 用struts2怎么不用第三方报表软件做报表 包括图表
- tomcat非正常退出,就再也启动不起来了。
- 在jsp中如何判断传来的字符串是8859-1编码还是gb2312编码方式
- 求助!!
String userIp=(String)session.getValue("userip");
if(userIp==null){
计数器加一;
String UserIp=request.getRemoteAddr();
session.putValue("userip",UserIp);
if(session.getAttribute("count")==null)
{
int count = 0 ;
File f = new File((request.getRealPath("/"))+"\\count\\count.txt");
BufferedReader br = new BufferedReader(new FileReader(f));
strCount=br.readLine() ;
count=Integer.parseInt(strCount)+1;
strCount=(new Integer(count)).toString();
PrintWriter pw = new PrintWriter(new FileWriter(f)) ;
pw.println(strCount);
pw.close();
session.setAttribute("count",strCount);
}
else
{
strCount = session.getAttribute("count").toString();
}
把计数器改成这样就行了。///////如何防止用户更新页面刷新计数器!