国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

jsp有兩個按鈕來控制Timer的開始和結(jié)束方法

2024-09-05 00:22:57
字體:
供稿:網(wǎng)友

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="結(jié)束" 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;@Controllerpublic 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的開始和結(jié)束方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持VeVb武林網(wǎng)。

 

注:相關(guān)教程知識閱讀請移步到JSP教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 新乡市| 洛阳市| 壤塘县| 黑水县| 莱西市| 杭州市| 桃江县| 庆城县| 荥阳市| 巴东县| 赞皇县| 庆云县| 城步| 秀山| 临汾市| 渝北区| 祥云县| 景洪市| 得荣县| 永春县| 自治县| 防城港市| 利川市| 镇原县| 行唐县| 张家口市| 鄂尔多斯市| 桑日县| 罗甸县| 南投县| 伊宁市| 台南市| 承德市| 丹东市| 开封县| 合水县| 锡林浩特市| 乃东县| 大荔县| 松江区| 政和县|