java Servlet小结
1:什么是Servlet?
① Servlet就是JAVA 类
② Servlet是一个继承HttpServlet类的类
③ 这个在服务器端运行,用以处理客户端的请求
2:Servlet 生命周期
Servlet 加载--->实例化--->服务--->销毁--->垃圾收集。
1>init():在Servlet的生命周期中,仅执行一次init()方法。它是在服务器装入Servlet时执行的,负责初始化Servlet 对象。可以配置服务器,以在启动服务器或客户机首次访问Servlet时装入Servlet。无论有多少客户机访问Servlet,都不会重复执行 init()。
2>service():它是Servlet的核心,负责响应客户的请求。每当一个客户请求一个HttpServlet对象,该对象的 Service()方法就要调用,而且传递给这个方法一个“请求”(ServletRequest)对象和一个“响应” (ServletResponse)对象作为参数。在HttpServlet中已存在Service()方法。默认的服务功能是调用与HTTP请求的方法 相应的do功能。==HttpServletRequest和HttpServletResponse类型的对象也是由容器创建的,容器会为不同的客户端创建相应的HttpServletRequest和HttpServletResponse对象
3>destroy(): 仅执行一次,在服务器端停止且卸载Servlet时执行该方法。当Servlet对象退出生命周期时,负责释放占用的资 源。一个Servlet在运行service()方法时可能会产生其他的线程,因此需要确认在调用destroy()方法时,这些线程已经终止或完成。
容器创建Servlet的对象是依据什么?
依据WebRoot--->WEB-INF--->web.xml配置文件创建。。
3: javax.servlet包的接口:
ServletConfig接口:在初始化的过程中由Servlet容器创建ServletConfig对象,可以获取初始化参数
ServletContext接口:定义Servlet用于获取来自其容器的信息的方法,可以获取上下文对象,他是全局的。每个servlet都可以获取到
ServletRequest接口:向服务器请求信息
ServletResponse接口:响应客户端请求
4:servlet中xml的配置
其中servlet节点和servlet-mapping节点下的servlet-name中的内容必须相同,init-param节点下配置初始化参数。。
5:示例代码
Demo1中有初始化和doGet方法以及Destory方法的执行,有ServletConfig对象的测试
package servelet; import java.io.IOException;
import java.io.PrintWriter; import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author qq
* Servlet是由容器(tomcat服务器)来创建对象的
* 当客户端请求该Servlet时,根据请求方式,容器调用Servlet的doGet()或doPost()方法
*
* 容器创建Servlet的对象是依据什么?依据WebRoot--->WEB-INF--->web.xml
* doGet()或doPost()方法的功能是定义给客户端发送的数据
*
* 每个Servlet只被创建一个对象,处理所有的客户端请求
* 一次运行,到处服务
*
*
* 只创建一个Servlet对象,怎么区分每个客户端?
* 容器会为不同的客户端创建相应的HttpServletRequest和HttpServletResponse对象
* 通过这两个对象来区分不同的客户端
*
*/
public class servlet extends HttpServlet { public servlet() {
super();
} /**
* 当Servelt实例从内存中消失前,容器会调用该方法
*/
public void destroy() {
System.out.println("=================被销毁了.........");
} /**
* request:封装了所有的客户端信息,代表的是客户端对象
*
* response:是服务器端对客户端的响应对象,封装了对客户端的响应信息
*
* 容器根据客户端的请求方式调用doGet()或doPost()方法,调用方法的同时
* 会传递HttpServletRequest和HttpServletResponse类型的对象,所以这
* 两个对象也是由容器创建的
*
* 容器会为不同的客户端创建相应的HttpServletRequest和HttpServletResponse对象
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html;charset=utf-8");//这条语句指明了向客户端发送的内容格式和采用的字符编码.
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the GET method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the POST method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
} /**
* 这个方法只在Servlet第一次被创建时调用,以后不再调用
*
*/
public void init() throws ServletException {
System.out.println("在Servlet的整个生命周期中,该方法只被调用一次"); //得到该 Servlet的配置参数
ServletConfig config = getServletConfig();//ServletConfig对象是容器创建的,获取ServletConfig对象
String value = (String)config.getInitParameter("name");
String pwd = (String)config.getInitParameter("pwd");
System.out.println(value+pwd); } }
Demo1
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhwAAACgCAIAAADICyIMAAAcYElEQVR4nO2dTbarOg6FGRcDYjx0q/cGUSvzqHYm8WZANZKAZGvLEpiTkOyvcde5RhGy/CNsEmv4999///nnn//893//+e//FkIIIeQAA4MKIYSQXsCgMo/Dg3G+y/L7emG6yfLbZAgL6eoDgIeesDi4Ly5HtOs7zhE9tnzWD7581kfX5OGDS9RwbS6zv92mRD/8Nba+PM73eezb3GyXt2AHFeHu2yQH9m1a58rbtJXf53GYbsttMoJKpps89VT6G/LVfaE9AFTf27TFhvs8NrVB+exwwfL3ebzITNuB7rNMnB13jvSQP6OX505tATnYgs8QbJe+es6gvf0lB7aapesR3yOoyEAV7QooeISDCrKhKNfaHs9YsHrhoGLpcY3w7S8QS55N46NwnO+vRzkVRp/PdvPUXuptz5mb5DxuHy8fEy358so4r567z+M0W0tjuZKLOcTUb9ujlon6xtj+xeqx5pPyc/acrOWmq99ks3Ucn30jb7/dH4AeOfvL/QCv3U2cQcF2EUqC7fI5NIPKbRKDtgwqxXg2g0qu7sq70Ur0DCqqvsoku7yulCXv+QEEFVP+No3TBDbqDOZRCIlV5nbbR8ltetxjWyje5zFyg9tNBqrVUPXQqZaftnz1xLoFFfm3iFt6qml1FaQf2bOgJ0Esv1iTFyqXy0111dXva5ar5D32W/0B6VHhQIwy2O4mzvBku2yXEu3yIbhBpdpqSQcVffWlS0SOYt4UXrvPk2wXLzb3Ciru1lJ2BxbKR/b1gPz9+TS4zbLeB6snQeUP8wlAKAytFPVDkwwq8s6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qMtn+5XL8mYn+VmhNr+Qv1Kapa7Jqheq+Kof8C4KHCDSjVvpYNKYf1Tl4gcRbx51WpZlvs8KYfasda9bzaouPN0drvJlM+t3Cz75TubhrLqZkqf+QQgGjTU9fXsIoOKvPNmiC0Pl1zFE7F+RsL9oQTod/2zXZP3jchL/Tk7QX2RflwO/W9pbpdfwE41Rairge2Tdjva8nv61RIPKtbHnn/AfiX9oIxwgspO/+De8n++/Isd8RAQ8wAAAABJRU5ErkJggg==" alt="" />
Demo2测试:
ServletContext的测试,先运行Demo2在运行Test 否则结构为null
package servelet; import java.io.IOException;
import java.io.PrintWriter; import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class Demo2 extends HttpServlet { /**
* Constructor of the object.
*/
public Demo2() {
super();
} /**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
} /**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html");
// 获取上下文对象
ServletContext context = getServletContext(); // 向上下文中放入数据
context.setAttribute("name", "lipeng");
} /**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to
* post.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the POST method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
} /**
* Initialization of the servlet. <br>
*
* @throws ServletException
* if an error occurs
*/
public void init() throws ServletException {
// Put your code here
} }
Demo2
package servelet; import java.io.IOException;
import java.io.PrintWriter; import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class Test extends HttpServlet { /**
* Constructor of the object.
*/
public Test() {
super();
} /**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
} /**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html");
PrintWriter out = response.getWriter();
ServletContext context = getServletContext();
String name = (String)context.getAttribute("name");
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.println("<h1>"+name+"<h1>");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
} /**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the POST method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
} /**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
} }
Test
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdcAAABkCAIAAABbz+35AAAJ80lEQVR4nO3dXYsb1x3H8Xk5vvLVogu13dcQCr4XDegmkLhgmkANXRubpQGDCMXZQgqbC1+EpZB6azUhCa1zsblIssluqa1Y1LvyxvXjpuOtiVVIql5ImjkP/zMP2pk9M9L3wxCkeTjnaM7oN0dHWicIJevr6+Lj0Wg0uHZm2Ft56VQw7K0Mrp0ZjUanfnH1lc7H3z4ZHjwZHjwdHjz5729/9ROp1O3VRtDamD7baAVBY3U7fhJt2miNH260tB3sx1oR8Wq9HqXyxuq2slUpcnu1Ede/vdpotFqN6TbXbsWp5RnWqol3tqqwOsM4vc6GWYcvRA+OWxifcuuFRY/V/tpebWTugoL7LuqvxMNr0ndhGL765vtbtx/9fXB06+B57/7zb/71/Jv7z/9x8J/dwbOt249effP9hKK2VxuNxuT1jR8rL0M+P+O1QWrL1MeDzTcO/9Ya9lZ2/7A87K0c/rV1b/ONv+x+O3g8HDwe7j8eDh4NB49fXDr3U0cjg5hypRkbpess4XEgHKdrbUjXgVJlo9VSrjeju127FaZ+Z1ivSVwrBYeyk7pKbpjy/h2/loXoQfOEGL0Ynw05hTN1QXF9F3eTdHj9+i4Mw0vvfPTJF72v98Kd/We7+0e7g6Pd/Wc7++HXe+EnX/QuvfNRUllq26OXbL4O/fS2WkEQ5Ezha2d+vHvx8NNzL50KDj899+M/Lw6undl7ONx7+GK83H344u7DFxd/6b7CvBNHyl7N2xkuGz1YX9XuuzAM3938/IObN+89uHt78GB3/+nO3nc7e09vDR4cPNj74ObNdzc/L6MN+VJ46/Lp/x1cDXudG7/7edjrjO5d3bp8+tdnl8+fXR7/9/xry+dfW/7N2Z+V0dZCGLeoKpizM1w2erC+Kt53Y2vvffjD0Vff/3s3fHrruye98PDW9+HuD0dfrb33YU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8Re6l/VmeuP++2cjMkKAKqT+T8eZR8JZjtE/wbM/gcbXAfHAWlNGbv/GDnpj6EdN4HEPw1hXAxAUXwKp/0oTEgox88KrJS1DtD/obKMY03x3ztLfxHTctM3OVOWP2MGYCl3RqIs1fwSLLVV0x2YlAAQIYULlDLWJYQB2OqZwgkztn45J38T/n02AAutdilch38ynV+rAcisdikMAHOFFAYAn0hhAPCJFAYAn0hhAPCJFAYAn0hhAPCJFAYAn0hhAPCJFAYAn0hhAPCJFAYAn0hhAPDp/+s9Ic1dQemHAAAAAElFTkSuQmCC" alt="" />
Demo3测试:
package servlet; import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class LoginServlet extends HttpServlet { /**
* Constructor of the object.
*/
public LoginServlet() {
super();
} public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
} //定义一个再编码再解码的功能
public static String deCode(String ss)
{
String str = null;
try{
byte[] arr = ss.getBytes("ISO8859-1");
str = new String(arr,"utf-8");
}catch(Exception e)
{
e.printStackTrace();
}
return str;
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
request.setCharacterEncoding("utf-8");//当使用post方式提交数据时,防止乱码的处理方式 //获取提交过来的用户名,因为属于客户端信息,所以从 request对象中获取
String username = request.getParameter("username");
//String username = deCode(uname);
//获取提交过来的密码
String psw = request.getParameter("pwd"); //验证
if(username!=null&&username!=""&&psw!=null&&psw!="")
{
if("李鹏".equals(username)&&"123".equals(psw))
{
out.println("<h1>"+"登陆成功"+"</h1>");
}
else
out.println("<h1>"+"登陆失败"+"</h1>");
}
out.flush();
out.close();
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
} public void init() throws ServletException {
// Put your code here
} }
LoginServlet
<html>
<head>
<base href="<%=basePath%>">
<title>登陆</title>
</head> <body>
<form action="servlet/LoginServlet" method="post">
用户名:<input type="text" name="username"><br>
密 码:<input type="password" name="pwd"><br>
<input type="submit" value="登陆"> <input type="reset" value="重置">
</form>
</body>
</html>
JSP
这里涉及到了编码也解码的问题。。
如果是get请求时,一种方法解决乱码问题: 把经过ISO8859-1的解码的字符串再使用ISO8859-1编码,在使用utf-8解码
如果是post请求时,除了可以使用上面的方法外,也可以通过request.setCharacterEncoding("utf-8");设置客户端请求的字符在服务器端的解码方式
结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWEAAACLCAIAAAA/Nb/QAAAM3ElEQVR4nO2dS28bxwGA96/sLSefCgFlWx+1uhAICvhOtABhUQHiAmYboAZqBA1kPQLwUATgoYAudpQQPaVhLwSaCHo4FwHNpWpU2pUfiiPHhW5mDil7WHJ3ZnZmdpcm96Xvw8LenZ2dmZ2d+TgzfMi5nDIejy++2B6d3H37LWd0cvfiiw/H43Fr5+CtX3201hmcv/rh/L+jb1+NPvzdTy81HK8vOY2eENBrOEvrx+KOhBiq21evOl5fmhz3Go6ck64Ux+tLzjQBoWh+qmFahmhzZGdnJ9gvSw3LiTiNnikLtUhq9RoL5l+kq/EqP8HL6R0IhdRXkc/x+pIzvbk868oR7//s/o3g/s/u3xiPx/7NP3s5evpy9PT70dOXP2z89mem+wnz7DUcqVGGp3oNfzeuBctJhMHaezteX/JPB2eFJI/Xl8L8j9eXlhqNoDOYos0PpYWVo4albMLIkSwiD0OpXmPBIpdfiSd4OS2x4tVIFR2vr4d3G2ogr7oKHXH22XuvvmiMTu5+/efro5O7r/7eePLZe3/7+tnZxejsYvSfi9HZd6Ozi9d/vP1zXTq+86YoahROTssV24In1ae5TqbR09WakOVSoyG0ZKVyTNHmhtjCylHDck7a0IbaguVyiEH6ggmt3b+XK/EE1duP3IEoC11d51RXgiPu3/jx0fuv9m6//Zbzau/2j8P3z+7fePxi9PjFa3979OL1oxev3/+N5f7z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rZqim2bNjf+4jmRE742A4yFSeTIklTzKF6oz6wh4hTzrVVOQhd3vEPsVWC8JOxA3kcrWQJzAc5C16Gm2IssA92i4teaJuB5ePc/JCFoncVVIU1nYWO+NgSMhEnhqjmT3gm3tOi06MEsoT96QWRfMhjD7RKzDytiiWJE/Tw844GBIye5iv71/K7/e4LhYRaKUlT4w6UXJC/7SE/JR4bhQXbOkin4jwCDvjYEjI8FnjOi9iPdtoiTIYeZIf5MlJEFsw3BgfHS3IOegf3Rj9mtn0eh7WdmCtk+m/QlBeb4///T8QeaL/qRxxa6R476a0CZX439PFeCYwgiew1sn2P7XQdysa3X8kMAh5ivyZMT8mzcqtR8IbDeR7J6h4DsETWOtk/I+kqBsL1btSGg3SylPMXwfTAmT0AEq9SkoSleAHLpqx9yV9AOSP/uUp1Ydzq7wvcr8lYic+spJocTK+C4I1iJE+mV0m4O0McQJDwED+iXn/pPJs7ZlqQVWFeBdA/AzJu2QsY6q7HgBYo+REngAAwwfkCQBgKZAnAIClQJ4AAJYCeQIAWArkCQBgKZAnAIClQJ4AAJYCeQIAWArkCQBgKZAnAIClQJ4AAJYCeQIAWArkCQBgKf8H+uGCA8PX748AAAAASUVORK5CYII=" alt="" />
java Servlet小结的更多相关文章
- [原创]java WEB学习笔记11:HttpServlet(HttpServletRequest HttpServletRsponse) 以及关于 Servlet 小结
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- Java中文编码小结
Java中文编码小结 1. 只有 字符到字节 或者 字节到字符 的转换才存在编码转码; 2. Java String 采用 UTF-16 编码方式存储所有字符.unicode体系采用唯一的码点表示唯一 ...
- Java 基础--小结
Java 基础--小结 java基础 Java源程序(.java文件)——>java字节码文件(.class文件)——>由解释执行器(java.exe)将字节码文件加载到java虚拟机( ...
- java servlet 几种页面跳转的方法及传值
java servlet 几种页面跳转的方法及传值 java web 页面之间传值有一下这几种方式1.form 表单传递参数2.url地址栏传递参数3.session4.cookie5.appli ...
- Java Servlet与Web容器之间的关系
自从计算机软件开发进入网络时代,就开始涉及到通讯问题.在客户/服务器(也叫C/S应用)时期,每个软件都有自己的客户端和服务器端软件.并且客户端和服务器端之间的通讯协议差别也很大.后来随着互联网的发展, ...
- java servlet调用带有多个返回结果集的存储过程
一.mysql存储过程 这里我先说下我这个功能实现的逻辑及途中遇到的一些问题.这个存储过程一共带两个输入参数,一共关联到两张表的查询,每个参数都对应查询表中的一个判断,所以一共返回了两个结果集(当然要 ...
- java servlet+mysql全过程(原创)
前段时间写过一篇 servlet+oracle的文章,但是那是因为公司有可能接那么一个项目,然后我当时也比较闲,所以随便学了下,那玩意是白去研究了,因为公司后面并没接到那项目. 这次学servlet用 ...
- java servlet+oracle 新手可看
最近公司领导告诉接下去接的一个产品,可能会涉及到oracle数据库,以前用得最多的是mssql,前些时间学了下mysql也算少许用过.oracle没接触过.应为我之前做过.net开发,所以数据访问接口 ...
- Java Servlet完全教程
Servlet 是一些遵从Java Servlet API的Java类,这些Java类可以响应请求.尽管Servlet可以响应任意类型的请求,但是它们使用最广泛的是响应web方面的请求. Servle ...
随机推荐
- web前端书籍
前端开发 必看的书籍资料(转自CSDN郭小北V5) 一. html + css 这部分建议在 w3school 在线教程 上学习,边学边练,每个属性后还有在线测试. 然后过一遍之后可以模仿一些网站做些 ...
- WordPress基础:订阅源rss的使用
设置->阅读,可设置rss显示效果 RSS源为:http://wordpress目录/feed 把这个地址放入你的rss阅读器进行订阅即可,最简单的就是使用QQ邮箱里面的阅读空间进行订阅.
- 使用SSIS汇集监控数据
1.背景 数据库服务器部署有各类巡检脚本,现在想把巡检收集到的数据汇集到一起.Source源对应的是各业务数据库服务器,Destination目标对应的是保存汇集数据的服务器.前期部署的时候已将巡检相 ...
- 关于sql优化的一个小总结
1.数据量大的时候,可以分多次查询2.有些数据的存储可以分主次表,此表存一些不常用的数据3.union all 比union效率要高4.尽量不要用distinct5.不返回不需要的行和列6.根据条件加 ...
- Java 使用GDAL 读写 shapefile
读取shp文件,并把它转化为json import org.gdal.ogr.*; import org.gdal.ogr.Driver; import org.gdal.gdal.*; public ...
- PythonNote01_HTML标签
>头标签<head> >>位置 头标签要放在头部之间 >>种类 <title> : 指定整个网页的标题,在浏览器最上方显示. <meta&g ...
- docker 使用非加密registry
配置docker成为服务,自启动 sudo systemctl enable docker.service 启动服务 sudo systemctl start docker docker默认要求我们使 ...
- js 简易的分页器插件
1.自己引入jquery插件,我的demo是引入的自己本地的query <!DOCTYPE html> <html> <head> <meta charset ...
- jQuery .attr("checked")得undefined 问题解决
出现此错误是因为JQuery版本升级的问题.所以此处应该使用.prop(); 那么,什么时候使用attr(),什么时候使用prop()?1.添加属性名称该属性就会生效应该使用prop();2.是有tr ...
- css3(border-radius)边框圆角详解
传统的圆角生成方案,必须使用多张图片作为背景图案.CSS3的出现,使得我们再也不必浪费时间去制作这些图片了,只需要border-radius属性,支持浏览器IE 9.Opera 10.5.Safari ...