jsp引入jsp和通过ajax引入jsp

jsp引入jsp有两种方式:

一:静态导入

静态导入不会给另一个jsp传参数,方式是:

<%@include file="play.js.jsp"%>

二:动态导入

动态导入能给另一个jsp传参数,也有两种方式:

1. include方式,特点:页面不会刷新,不会清除当前页的任何数据,会引入play.js.jsp这个jsp内容不会跳转到这个jsp

<pre name="code" class="html"><jsp:include page="play.js.jsp" flush="true">
	<jsp:param name="video" value="http://192.168.100.48:8002/res/data/coursewarePkg/output/778/778_8672_12_1378548319870.mp4"/>
</jsp:include>

 
 

2. forward方式,特点:页面不会刷新,但是会清除当前页面的body引入play.js.jsp的body,类似于跳转到了这个jsp

<jsp:forward page="play.js.jsp" flush="true">
	<jsp:param name="video" value="http://192.168.100.48:8002/res/data/coursewarePkg/output/778/778_8672_12_1378548319870.mp4"/>
</jsp:forward>

三:ajax导入

ajax方式,当前页面不刷新,但是调用一次videoRefresh()函数,这个div下面的jsp会变化一次,同时页面不刷新,但是引入的jsp会刷新

play.jsp:

<div id="videoPlay" class="playerCenter">
  
</div> 

js:

<script type="text/javascript"> 

function videoRefresh(reUrl){
	var url = "请求地址";
	$.ajax({
		type : "get",
		async : false,  //同步请求
		url : "play.js.jsp",
		data : {video:reUrl},
		success:function(dates){
			//alert(dates);
			$("#videoPlay").html(dates);//要刷新的div
		},
		error: function() {
           // alert("失败,请稍后再试!");
        }
	});
}

</script>

plsy.js.jsp:

<!DOCTYPE html>
<%@ page language="java"  pageEncoding="utf-8"%>
<head>
  <!-- 此页面纯粹只用播放功能
       由其它的jsp页面调用本页面
  	   video:是视频http地址		
   -->
   
  <!-- Chang URLs to wherever Video.js files will be hosted -->
  <link href="/video/video-js.css" rel="stylesheet" type="text/css" />
  <!-- video.js must be in the <head> for older IEs to work. -->
  <script src="/video/video.js"></script>

  <!-- Unless using the CDN hosted version, update the URL to the Flash SWF -->
  <script>
  	 videojs.options.flash.swf = "/video/video-js.swf";
  </script>

</head>

<% String video = request.getParameter("video"); %>
<div class="playVideo">
  <video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="1000" height="540"
      poster="oceans-clip.png"
      data-setup="{}">
    <source src="<%=video %>" type='video/mp4' />
    <!--  <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
    <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' /> -->
    <!-- <track kind="captions" src="demo.captions.vtt" srclang="en" label="English"></track> --><!-- Tracks need an ending tag thanks to IE9 -->
    <!-- <track kind="subtitles" src="demo.captions.vtt" srclang="en" label="English"></track> --><!-- Tracks need an ending tag thanks to IE9 -->
  </video>
</div>

<script type="text/javascript">
	//自动播放
    var myPlayer = videojs('example_video_1');
    videojs("example_video_1").ready(function(){
        var myPlayer = this;
        myPlayer.play();
    });
</script>


以上三种方式均可以使用,亲测,不能实现慢慢调试!


你可能感兴趣的:(Ajax,jsp)