欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jsp有兩個(gè)按鈕來(lái)控制Timer的開(kāi)始和結(jié)束方法

 更新時(shí)間:2017年03月31日 11:40:26   投稿:jingxian  
下面小編就為大家?guī)?lái)一篇jsp有兩個(gè)按鈕來(lái)控制Timer的開(kāi)始和結(jié)束方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

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="開(kāi)始" 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;

@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有兩個(gè)按鈕來(lái)控制Timer的開(kāi)始和結(jié)束方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論