无为清净楼资源网 Design By www.qnjia.com
1、jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript"> function st(){ window.location.href="startCamera.html" rel="external nofollow" ; } function en(){ window.location.href="cancelCamera.html" rel="external nofollow" ; } </script> </head> <body> <input type="button" value="开始" onclick="st()"/><input type="button" value="结束" onclick="en()"/> </body> </html>
2、Controller
package net.spring.controller; import java.util.Timer; import net.spring.utils.CameraTask; import net.spring.utils.HKTest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HKController { public Timer timer = null; public CameraTask mCameraTask = null; public static boolean status = false; @RequestMapping("startCamera") public String startCamera() { if (!status) { // HKTest.getInstance().login(); if (timer == null) { timer = new Timer(); } if (mCameraTask == null) { mCameraTask = new CameraTask(); } timer.schedule(mCameraTask, 0, 1000); status = true; } return "camera"; } @RequestMapping("cancelCamera") public String cancelCamera() { if (status) { if (timer != null) { timer.cancel(); timer = null; } if (mCameraTask != null) { mCameraTask.cancel(); mCameraTask = null; } // HKTest.getInstance().logout(); status = false; } return "camera"; } }
3、TimerTask
package net.spring.utils; import java.util.TimerTask; public class CameraTask extends TimerTask { @Override public void run() { //dosomthing; } }
以上这篇jsp有两个按钮来控制Timer的开始和结束方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
标签:
jsp,timer
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年09月20日
2024年09月20日
- 《第9层》游戏特色玩法介绍
- 刀郎.2006-刀郎【九雨天下】【WAV+CUE】
- 59.9高校生.1994-素兰万岁【上华】【WAV+CUE】
- ECHO.1991-你是爱我还是需要我(国专)【EMI百代】【WAV+CUE】
- 交错战线零课主线困难通关阵容推荐一览
- 交错战线挖掘矿场角色推荐攻略
- 命运圣契公测平民阵容怎么搭配 新手开荒平民阵容攻略
- 金梅《现代发烧的声音2》发烧碟[WAV+CUE]
- 雨果唱片-《历史录音珍藏系列-现代芭蕾舞剧·红色娘子军》2CD【WAV】
- [雨果唱片]李冰《地方民歌·戏曲系列-爱的颂歌》WAV
- 《模拟人生》真人电影官宣!玛格特·罗比担任制片人
- 《星战绝地》系列玩家数超4000万!续作表现超预期
- EA称AI是其业务核心!能提高开发效率、节约成本
- 《十年经典成名好歌 高品质最佳音乐 2CD》[WAV/分轨][1GB]
- 《8个男人的故事 2CD》[WAV/分轨][1GB]