JQUERY彈幕網(wǎng)AJAX加載下拉框數(shù)據(jù),封裝,CDN修改別人腳本文件,亂碼處理【詩(shī)書(shū)畫(huà)唱】

package com.jy.controller;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jy.bean.Dminfo;
import com.jy.dao.DminfoDao;
/**
?* Servlet implementation class DanmuServlet
?*/
@WebServlet("/ds")
public class DanmuServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
? ? ? ?
? ? /**
? ? ?* @see HttpServlet#HttpServlet()
? ? ?*/
? ? public DanmuServlet() {
? ? ? ? super();
? ? ? ? // TODO Auto-generated constructor stub
? ? }
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
this.doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String method = request.getParameter("method");
DminfoDao dminfoDao = new DminfoDao();
if("save".equals(method)) {
//獲取輸入的彈幕的信息
String text = request.getParameter("text");
//中文亂碼處理
text = new String(text.getBytes("iso8859-1"),"utf-8");
System.out.println(text);
String color = request.getParameter("color");
System.out.println(color);
String strSize = request.getParameter("size");
Integer size = parseToNum(strSize);
String strPosition = request.getParameter("position");
Integer position = this.parseToNum(strPosition);
String strTime = request.getParameter("time");
Integer time = this.parseToNum(strTime);
//封裝數(shù)據(jù)
Dminfo dm = new Dminfo();
dm.setText(text);
dm.setColor(color);
dm.setSize(size);
dm.setPosition(position);
dm.setTime(time);
dminfoDao.add(dm);
} else {
//String jsonStr = "{dms:[{\"text\":\"神光護(hù)體\",\"color\":\"#0000EE\",\"size\":1,\"position\":0,\"time\":112}]}";
List<Dminfo>list = dminfoDao.selectAll();
StringBuilder jsonStr = new StringBuilder();
jsonStr.append("{dms:[");
String dot = "";
for(Dminfo dm : list) {
jsonStr.append(dot);
jsonStr.append("{\"text\":\"");
jsonStr.append(dm.getText());
jsonStr.append("\",\"color\":\"");
jsonStr.append(dm.getColor());
jsonStr.append("\",\"size\":");
jsonStr.append(dm.getSize());
jsonStr.append(",\"position\":");
jsonStr.append(dm.getPosition());
jsonStr.append(",\"time\":");
jsonStr.append(dm.getTime());
jsonStr.append("}");
dot = ",";
}
jsonStr.append("]}");
System.out.println(jsonStr);
response.setCharacterEncoding("utf-8");
response.getWriter().write(jsonStr.toString());
}
}
? ??
//將字符串轉(zhuǎn)換成整型變量的方法
private Integer parseToNum(String s){
Integer num = null;
if(s != null && s.length() > 0) {
num = Integer.parseInt(s);
}
return num;
}
}


——————

前言:彈幕網(wǎng)的效果和個(gè)人對(duì)其的理解是“查詢彈幕”就是在對(duì)應(yīng)的時(shí)間軸顯示,從數(shù)據(jù)庫(kù)中查出來(lái)。效果是發(fā)彈幕時(shí)可以保存彈幕到數(shù)據(jù)庫(kù),同時(shí),刷新時(shí)在對(duì)應(yīng)的部分會(huì)從數(shù)據(jù)庫(kù)查詢出彈幕,并在對(duì)應(yīng)的時(shí)間軸顯現(xiàn)。
亂碼處理:

下面含我自己想出來(lái)的修改別人的腳本文件高效的好方法。
有些自己想出來(lái),的確是值得驕傲的一件事?!?shī)書(shū)畫(huà)唱
分享自己的學(xué)習(xí)方法(我有時(shí)會(huì)毫無(wú)保留地分享我的方法,當(dāng)然自己獲得這些方法肯定比你們直接到我這里獲取方法耗時(shí)多,同時(shí)毅力和耐心很重要,我的方法會(huì)分享很多,你不堅(jiān)持學(xué)完,有時(shí)只會(huì)是一知半解,只會(huì)皮毛,想比一些人更強(qiáng)等的目標(biāo)等也不會(huì)那么容易實(shí)現(xiàn)):
看教程視頻是,從頭到尾看,遇到自己認(rèn)為好的就是親自動(dòng)手,截圖,寫文字到b站專欄的草稿箱,之后可以發(fā)布。遇到認(rèn)為會(huì)的,容易等的就在這段時(shí)間做別的事。很多時(shí)候可以2倍或1.5倍速看。
——————————
有些時(shí)候一些JS等的腳本文件自己會(huì)寫,但可能會(huì)花很多不必要的時(shí)間,所以為了更好的滿足自己的需求和節(jié)省時(shí)間成高效,要自己學(xué)會(huì)修改別人寫的腳本文件,之后去用。






——————
作業(yè)和我給出的答案:
加載下拉框數(shù)據(jù)


package com.SSHC.bean;
public class Addr {
? ? private Integer id;
? ? private Integer pid;
? ? private String name;
? ? public Addr(Integer id,String n){
? ? this.id = id;
? ? this.name = n;
? ? }
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getPid() {
return pid;
}
public void setPid(Integer pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

package com.SSHC.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.SSHC.bean.Addr;
/**
?* Servlet implementation class ProvServlet
?*/
@WebServlet("/ps")
public class ProvServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
? ? ? ?
? ? /**
? ? ?* @see HttpServlet#HttpServlet()
? ? ?*/
? ? public ProvServlet() {
? ? ? ? super();
? ? ? ? // TODO Auto-generated constructor stub
? ? }
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
this.doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//獲取省份下拉框中的數(shù)據(jù)(這里暫時(shí)用數(shù)組代替數(shù)據(jù)庫(kù)查詢)
List<Addr>list = new ArrayList<Addr>();
Addr a1 = new Addr(1,"湖南");
Addr a2 = new Addr(2,"湖北");
Addr a3 = new Addr(3,"江西");
Addr a4 = new Addr(4,"福建");
list.add(a1);
list.add(a2);
list.add(a3);
list.add(a4);
//方法一:拼接Html字符串
//拼接一段html:將list中的數(shù)據(jù)全部轉(zhuǎn)換成html代碼
//<option value='1'>湖南</option>
// StringBuilder html = new StringBuilder();
// for(Addr addr : list) {
// html.append("<option value='");
// html.append(addr.getId());
// html.append("'>");
// html.append(addr.getName());
// html.append("</option>");
// }
// response.setCharacterEncoding("utf-8");
// //將html代碼提交到回調(diào)函數(shù)中
// response.getWriter().write(html.toString());
//方法二:拼接JSON字符串
//[{"id":1,"name":"湖南"},{"id":2,"name":"湖北"}]
StringBuilder jsonStr = new StringBuilder("[");
String dot = "";
for(Addr addr : list) {
jsonStr.append(dot);
jsonStr.append("{\"id\":");
jsonStr.append(addr.getId());
jsonStr.append(",\"name\":\"");
jsonStr.append(addr.getName());
jsonStr.append("\"}");
dot = ",";
}
jsonStr.append("]");
response.setCharacterEncoding("utf-8");
response.getWriter().write(jsonStr.toString());
}
}


<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
? ? String path = request.getContextPath();
? ? String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
? ? <head>
? ? ? ? <base hreff="<%=basePath%>">
? ? ? ? <title></title>
? ? ? ? <meta http-equiv="pragma" content="no-cache">
? ? ? ? <meta http-equiv="cache-control" content="no-cache">
? ? ? ? <meta http-equiv="expires" content="0">
? ? ? ? <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
? ? ? ? <meta http-equiv="description" content="This is my page">
? ? ? ? <script type="text/javascript" srcc="js/jquery-1.11.0.js"></script>
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? $(function(){
? ? ? ? ? ? //提交一個(gè)請(qǐng)求下拉框數(shù)據(jù)的ajax請(qǐng)求
? ? ? ? ? ? $.ajax({
? ? ? ? ? ? url: 'ps',
? ? ? ? ? ? type: 'POST',
? ? ? ? ? ? success: function(data){
? ? ? ? ? ? //方法一:
? ? ? ? ? ? //$('#prov').html(data);
? ? ? ? ? ? //方法二:
? ? ? ? ? ? //將data轉(zhuǎn)換成真正的js對(duì)象
? ? ? ? ? ? var arr = JSON.parse(data);
? ? ? ? ? ? //var arr = eval('(' + data + ')');
? ? ? ? ? ? for(var i = 0;i < arr.length;i ++) {
? ? ? ? ? ? var ad = arr[i];
? ? ? ? ? ? //將選項(xiàng)放到下拉框中去
? ? ? ? ? ? $('#prov').append($('<option value="'?
? ? ? ? ? ? + ad.id + '">'
? ? ? ? ? ? + ad.name + '</option>'));
? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? });
? ? ? ? ? ? });
? ? ? ? </script>
? ? </head>
? ? <body>
? ? ? ? <select id="prov"></select>
? ? </body>
</html>


實(shí)現(xiàn)彈幕保存功能。
彈幕網(wǎng):
create table Dminfo(
id int primary key auto_increment,
text varchar(100) ,
color varchar(100) ,
size int,
position int,
time int
);
select * from Dminfo
drop table Dminfo




package com.SSHC.bean;
public class Dminfo {
? ? private Integer id;//彈幕編號(hào)
? ? private String text;//彈幕內(nèi)容
? ? private String color;//彈幕的字體顏色
? ? private Integer size;//彈幕的字體大小
? ? private Integer position;//彈幕的顯示位置
? ? private Integer time;//彈幕顯示時(shí)間
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public Integer getSize() {
return size;
}
public void setSize(Integer size) {
this.size = size;
}
public Integer getPosition() {
return position;
}
public void setPosition(Integer position) {
this.position = position;
}
public Integer getTime() {
return time;
}
public void setTime(Integer time) {
this.time = time;
}
}

package com.SSHC.controller;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.SSHC.bean.Dminfo;
import com.SSHC.dao.BaseDao;
import com.SSHC.dao.DminfoDao;
/**
?* Servlet implementation class DanmuServlet
?*/
@WebServlet("/ds")
public class DanmuServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
? ? ? ?
? ? /**
? ? ?* @see HttpServlet#HttpServlet()
? ? ?*/
? ? public DanmuServlet() {
? ? ? ? super();
? ? ? ? // TODO Auto-generated constructor stub
? ? }
/**
* @see HttpServlet#doGet(HttpServletRequest request,
*? HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response)?
throws ServletException, IOException {
// TODO Auto-generated method stub
this.doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest?
* request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request,?
HttpServletResponse response)?
throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("GBK");
String method = request.getParameter("method");
if("save".equals(method)) {
//獲取輸入的彈幕的信息
String text = request.getParameter("text");
String text2=
new String(text.getBytes("iso8859-1"),"UTF-8") ;
System.out.println(text2);
String color = request.getParameter("color");
System.out.println(color);
String strSize = request.getParameter("size");
System.out.println(strSize);
String strPosition = request.getParameter("position");
System.out.println(strPosition);
String strTime = request.getParameter("time");
System.out.println(strTime);
DminfoDao A=new DminfoDao();
Dminfo B=new Dminfo();
B.setText(text2);
B.setColor(color);
B.setPosition(Integer.valueOf(strPosition));
B.setSize(Integer.valueOf(strSize));
B.setTime(Integer.valueOf(strTime));
try {
A.add(B);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String S;
if(BaseDao.countAdd!=null) {
?S="添加成功!";
//request.setAttribute("B", S);
//request.getRequestDispatcher("ManageAllUserServlet")
//
// .forward(request, response);
?
?System.out.println(S);
}else
{
?S="添加失?。?#34;;
?System.out.println(S);
?}
} else {
System.out.println("查詢彈幕");
//String jsonStr = "{dms:[{\"text\":\"神光護(hù)體\",\"color\":\"#0000EE\",\"size\":1,\"position\":0,\"time\":112}]}";
DminfoDao ud = new DminfoDao();
List<Object> list;
try {
list = ud.selectAll(Dminfo.class,null);
StringBuilder jsonStr = new StringBuilder();
jsonStr.append("{dms:[");
String dot = "";
for(Object o : list) {
Dminfo dm = ( Dminfo)o;
jsonStr.append(dot);
jsonStr.append("{\"text\":\"");
jsonStr.append(dm.getText());
jsonStr.append("\",\"color\":\"");
jsonStr.append(dm.getColor());
jsonStr.append("\",\"size\":");
jsonStr.append(dm.getSize());
jsonStr.append(",\"position\":");
jsonStr.append(dm.getPosition());
jsonStr.append(",\"time\":");
jsonStr.append(dm.getTime());
jsonStr.append("}");
dot = ",";
}
jsonStr.append("]}");
System.out.println(jsonStr);
response.setCharacterEncoding("utf-8");
response.getWriter().write(jsonStr.toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}


package com.SSHC.dao;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.SSHC.util.DbUtil;
//萬(wàn)能Dao
//T不是一個(gè)具體的java類,他是一個(gè)泛型參數(shù)
public class BaseDao<T> {
? ? public<T> List<T>selectAll(Class cls,String SQL) throws Exception{
? ? Connection conn = null;
? ? PreparedStatement pstm = null;
? ? ResultSet rs = null;
? ? List<T>list = new ArrayList<T>();
? ? //通過(guò)反射技術(shù)獲取表的名字,表的名字剛好和bean的名字一樣
? ? //獲取類的類名
? ? String tableName = cls.getSimpleName();
? ? String sql=null;
? ? if(SQL==null){
? ? sql = "select * from " + tableName;}
? ? else if(SQL!=null){
? ? ? ? sql = "select * from " + tableName
? ? ? ? +SQL;}
? ? System.out.println(sql);
? ?
? ? conn = DbUtil.getConn();
? ? pstm = conn.prepareStatement(sql);
? ? rs = pstm.executeQuery();
? ? //獲取bean中的所有屬性名
Field []fs = cls.getDeclaredFields();
? ? while(rs.next()) {
? ? //通過(guò)反射創(chuàng)建出cls對(duì)象的實(shí)例
? ? Object obj = cls.newInstance();
? ? for(int i = 0;i < fs.length;i ++) {
? ? //bean中的屬性名
? ? String fname = fs[i].getName();
? ? //獲取bean中的屬性的類型
? ? Class type = fs[i].getType();
? ? Object o = rs.getObject(fname);
? ? //System.out.println(o);?
? ? //將屬性對(duì)應(yīng)的set方法名拼接出來(lái)
? ? //取出屬性名的首字母,將它變成大寫
? ?String methodName = "set"?
? ? + fname.substring(0,1).toUpperCase()?
? ? + fname.substring(1);
? ? //System.out.println(methodName);
? ? //通過(guò)反射調(diào)用set方法
? Method m = cls.getDeclaredMethod(methodName, type);
? ? System.out.println(m);
? ? m.invoke(obj, o);? ?
? ? }
list.add((T)obj);
? ? }
? ? return list;
? ? }
public static Integer countAdd;
? ? public Integer add(T t) throws Exception{
? ? Connection conn = null;
? ? PreparedStatement pstm = null;
Integer count = -1;
? ? String tableName = t.getClass().getSimpleName();
?//System.out.println(tableName);
StringBuilder sql = new StringBuilder("insert into "
?+ tableName + " (");
?//取出t對(duì)象中的所有的屬性名
? ? Field []fs = t.getClass().getDeclaredFields();
? ? String dot = "";
? ? for(int i = 0;i < fs.length;i ++) {
? ? sql.append(dot);
? ? String fname = fs[i].getName();
? ? sql.append(fname);
? ? dot = ",";
? ? }
? ? sql.append(")values(");
? ? String dot1 = "";
? ? for(int i = 0;i < fs.length;i ++) {
? ? sql.append(dot1);
? ? sql.append("?");
? ? dot1 = ",";
? ? }
? ? sql.append(")");
? ? //System.out.println(sql);
? ?
? ? conn = DbUtil.getConn();
? ? pstm = conn.prepareStatement(sql.toString());
? ? //調(diào)用t對(duì)象中所有的get方法
? ? for(int i = 0;i < fs.length;i ++) {
? ? //取出屬性名
? ? String fname = fs[i].getName();
? ? //拼接get方法
String methodName = "get"?
? ? + fname.substring(0,1).toUpperCase()
? ? + fname.substring(1);
? ? //取出需要調(diào)用的方法
Method m = t.getClass().getDeclaredMethod(methodName);
? ? //反射調(diào)用get方法
? ? Object val = m.invoke(t);
? ? System.out.println("新增的數(shù)據(jù)是:" + val);
? ? //設(shè)置占位符
? ? pstm.setObject(i + 1, val);
? ? }
? ? count = pstm.executeUpdate();
? ? countAdd=count;
? ? System.out.println(countAdd);
? ? return count;
? ? }
? ? public static Integer countUpdate;
? ? public Integer update(T t) throws Exception{
? ? Connection conn = null;
PreparedStatement pstm = null;
Integer count = -1;
StringBuilder sql = new StringBuilder("update ");
//獲取表名,就是獲取t對(duì)象的類名
Class cls = t.getClass();
String tableName = cls.getSimpleName();
sql.append(tableName + " set ");
//獲取t對(duì)象的所有屬性名
Field[]fs = cls.getDeclaredFields();
//每個(gè)javabean的第一個(gè)屬性必須是id
//下標(biāo)是從1開(kāi)始的,也就是排除了id屬性
String dot = "";
//定義一個(gè)List存放所有的修改的值
List<Object>params = new ArrayList<Object>();
for(int i = 0;i < fs.length;i ++) {
Field f = fs[i];
//獲取屬性名
String fname = f.getName();
System.out.println("下標(biāo)為"+i+"的屬性名:"+fname);
//調(diào)用getXXX方法來(lái)獲取t中的屬性值
String methodName = "get"?
+ fname.substring(0,1).toUpperCase()
+ fname.substring(1);
System.out.println(methodName);
//通過(guò)反射獲取方法對(duì)象
Method m = cls.getDeclaredMethod(methodName);
//反射調(diào)用getXXX方法
Object obj = m.invoke(t);
? ? ? ? ? ??
//當(dāng)獲取到的值不為空時(shí),才能進(jìn)行修改
if(obj != null) {
sql.append(dot);
sql.append(fname + " = ? ");
dot = ",";
params.add(obj);
}
}
//將id也放到params容器中去
// Method m1 = cls.getDeclaredMethod("getId");
Method m1 = cls.getDeclaredMethod(
"get"?
+fs[0].getName().substring(0,1)
.toUpperCase()
+ fs[0].getName().substring(1));
Object id = m1.invoke(t);
params.add(id);
//拼接where條件
fs[0].getName();
System.out.println("這個(gè)表的第一列的列名"
+ "(一般都為編號(hào)名)為:"+fs[0].getName());
// sql.append("where id = ? ");
sql.append("where "+fs[0].getName()+" = ? ");
System.out.println(sql);
conn = DbUtil.getConn();
pstm = conn.prepareStatement(sql.toString());
//設(shè)置占位符的值
for(int i = 0;i < params.size();i ++) {
pstm.setObject(i + 1, params.get(i));
}
System.out.println("這時(shí)執(zhí)行的修改語(yǔ)句為:"+sql);
count = pstm.executeUpdate();
countUpdate=count;
? ? return count;
? ? }
//? ? public Integer delete(Integer id){
//? ? return 0;
//? ? }
? //萬(wàn)能Dao刪除方法
? ? public static Integer countDelete;
? ? public Integer delete(Integer id,Class cls)?
? ? throws Exception{
? ? Connection conn = null;
PreparedStatement pstm = null;
Integer count = -1;
String tableName = cls.getSimpleName();
Field[]fs = cls.getDeclaredFields();
for(int i = 0;i < fs.length;i ++) {
Field f = fs[i];
//獲取屬性名:fs[i].getName();
String fname = f.getName();
System.out.println("下標(biāo)為"+i+"的屬性名:"+fname);
//調(diào)用getXXX方法來(lái)獲取t中的屬性值
String methodName = "get"?
+ fname.substring(0,1).toUpperCase()
+ fname.substring(1);
System.out.println(methodName);
//通過(guò)反射獲取方法對(duì)象
Method m = cls.getDeclaredMethod(methodName);
//反射調(diào)用getXXX方法
//當(dāng)獲取到的值不為空時(shí),才能進(jìn)行修改
}
// String sql = "delete from " + tableName
// + " where id = ?";
String sql = "delete from " + tableName
+ " where "+fs[0].getName()+" = ?";
conn = DbUtil.getConn();
pstm = conn.prepareStatement(sql);
pstm.setInt(1, id);
count = pstm.executeUpdate();
countDelete=count;
? ? return count;
? ? }
? ? public static void main(String[] args) throws Exception {
//? ? Dao ud= new Dao();
//
////? ? User u = ud.selectByActAndPwd("1","1",null);
//? ? User u = ud.selectByActAndPwd(null,null,1);
//? ? System.out.println(u.getAct());?
//? ? System.out.println(u.getId());?
//? ? ? List<Object> list1;
//
//? ? list1 = D.selectAll(Comments.class);
//
//? ?
//? ? ??
//? ? ? ?for(Object o : list1) {
//? ? Comments C= (Comments)o;
//? ? System.out.println(C.getCommentsId());
//? ? System.out.println(C.getId());
//? ? ? System.out.println(C.getCommentsId());
? ?
? ? ? ?}
? ? ?
? ? ??
? ? ?
? ?
}

package com.SSHC.dao;
import com.SSHC.bean.Dminfo;
public class DminfoDao extends BaseDao<Dminfo> {
}

package com.SSHC.util;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;
public class DbUtil {
private static String driverName;
? ? private static String url;
? ? private static String user;
? ? private static String pwd;
? ??
? ? static {
? ? //讀取properties文件
? ? Properties prop = new Properties();
? ? //將db.properties文件讀取到內(nèi)存中去
? ? InputStream is = DbUtil.class.getClassLoader()
? ? .getResourceAsStream("db.properties");
? ? //加載內(nèi)容
? ? try {
prop.load(is);
//讀取內(nèi)容
driverName = prop.getProperty("dn");
url = prop.getProperty("url");
user = prop.getProperty("un");
pwd = prop.getProperty("up");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
? ? }
? ??
? ? //獲取數(shù)據(jù)庫(kù)連接對(duì)象的方法
? ? public static Connection getConn(){
? ? Connection conn = null;
? ? try {
Class.forName(driverName);
conn = DriverManager.getConnection(url,user,pwd);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}? ?
? ? return conn;
? ? }
? ??
? ? public static void close(ResultSet rs,PreparedStatement pstm
? ? ,Connection conn){
? ? ? ? try {
? ? ? ? if(rs != null) {
? ? ? ? ? ? rs.close();
? ? ? ? ? ? }
? ? ? ? ? ? if(pstm != null) {
? ? ? ? ? ? pstm.close();
? ? ? ? ? ? }
? ? ? ? ? ? if(conn != null) {
? ? ? ? ? ? conn.close();
? ? ? ? ? ? }
? ? ? ? } catch(Exception e) {
? ? ? ? e.printStackTrace();
? ? ? ? }
? ? }
}

dn=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/firstjsp?useUnicode=true&characterEncoding=utf-8
un=root
up=root



<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
? ? String path = request.getContextPath();
? ? String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
? ? <head>
? ? ? ? <base hreff="<%=basePath%>">
? ? ? ? <title></title>
? ? ? ? <meta http-equiv="pragma" content="no-cache">
? ? ? ? <meta http-equiv="cache-control" content="no-cache">
? ? ? ? <meta http-equiv="expires" content="0">
? ? ? ? <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
? ? ? ? <meta http-equiv="description" content="This is my page">
? ? ? ? <link rel="stylesheet" type="text/css" href="css/danmuplayer.css">
? ? ? ? <script type="text/javascript" srcc="js/jquery-1.11.0.js"></script>
? ? ? ? <script type="text/javascript" srcc="js/danmuplayer.js"></script>
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? $(function(){
? ? ? ? ? ? $('#danmup').danmuplayer({
? ? ? ? ? ? src: 'a.mp4',//視頻的路徑
? ? ? ? ? ? width: 1200,//屏幕寬度1200px
? ? ? ? ? ? height: 600,//屏幕高度600px
? ? ? ? ? ? speed: 20000,//彈幕飄過(guò)的速度,穿過(guò)視頻屏幕的時(shí)間
? ? ? ? ? ? danmuss: {},
? ? ? ? ? ? default_font_color: '#FFFFFF',//默認(rèn)的彈幕顏色
? ? ? ? ? ? font_size_small: 50,//小號(hào)彈幕字體大小
? ? ? ? ? ? font_size_big: 75,//大號(hào)彈幕字體大小
? ? ? ? ? ? opacity: '1',//彈幕字體的透明度,為0則完全透明
? ? ? ? ? ? top_botton_danmu_time: 6000,//底部及頂部彈幕存留的時(shí)間
? ? ? ? ? ? url_to_get_danmu: 'ds?method=query',//獲取所有彈幕信息的url
? ? ? ? ? ? url_to_post_danmu: 'ds?method=save'//保存彈幕信息的url
? ? ? ? ? ? });
? ? ? ? ? ? })
? ? ? ? </script>
? ? </head>
? ? <body>
? ? ? ? <div id="danmup"></div>
? ? </body>
</html>











——————————————————

CDN的全稱是Content Delivery Network,即內(nèi)容分發(fā)網(wǎng)絡(luò)。CDN是構(gòu)建在現(xiàn)有網(wǎng)絡(luò)基礎(chǔ)之上的智能虛擬網(wǎng)絡(luò),依靠部署在各地的邊緣服務(wù)器,通過(guò)中心平臺(tái)的負(fù)載均衡、內(nèi)容分發(fā)、調(diào)度等功能模塊,使用戶就近獲取所需內(nèi)容,降低網(wǎng)絡(luò)擁塞,提高用戶訪問(wèn)響應(yīng)速度和命中率。CDN的關(guān)鍵技術(shù)主要有內(nèi)容存儲(chǔ)和分發(fā)技術(shù)。