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的配置

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqQAAAEcCAIAAACeVTF7AAAgAElEQVR4nO2d367jRLaHcx7gXJ8XQSNNbjYvgtBIW34LlAgp0khzcSIxPhHXSJkLw1wgCBqQRuNMGEB0q9X0tBt1RDcbaNTqNBtoYPefafC5sF2uP6sqyd5JdmJ/nyzotpfLZbu6fl6rKrU6+cr88MMPqxsDAADAntBZ3RSxBwAAOEQQewAAgIaD2AMAADQcx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XhZn5/nc4np2mxXrlg/pMfN6App+FdMttu3NcLc3zO7uPOj6G3PxqnZb7PROwqc9+9szYs/Wqq31Yr/bzQp7Htr27ksdwWE9nO2w6+//nX32kvd3E9vdDro9I/ZsrdoQ+91ttY8SGIk82C3vv3gQfz7c+u/bcrmH3p4Re7ZWbYg92wa2Qo32/78HXf99E/tD3xB7tlZtiD3bRbf98X1X//Mh1p989pvdEHu2Vm3nEXsAAAA4IBB7AACAhoPYAwAANBzEHgAAoOEcsNjPp6PudHHZtQAAANh3Dlfss6j/1mRXFztJy8W5jtMD/ryYJYddfwAAOB8HIPbz6ajj6PqluPUnaby6WI7jZLbV2lwCWdTvE00BADg49lvsF9Nuv98ZTZ0Dgls/jqv1vOL4OE6rEtJjtYa22lkZH6eLymVPZnk+S3q1+54l7lmC2Ivl6zt7vaNeb5AF7jE97vWO4nhQVKO8bvWhoKqhBRXGce+oF49TdSgeL0L7c09kotg5SOo1ybWvk2ygCkkT/cThqN/pj4YoPgDA4bC/Yh8QFdet12V4ltS6O45NwdOUu9TRYk+WFHpsyHmWHCWGSrtiHyh/Dc9+kR4XHwRZUijuSRqX3wdZpgoZx/VHwzjWtHmRHld/9u331f8kjZW9frS+1iI9dgcvvB9hAACwj+yj2M+no04oXCyO1itP1FI7O4tXLX5ZIsXks0EtnLWQF9hiGSxfEnu9kpr9Ij2uvjmKz4ta7M1L6GKvRwuUvW+/XH/LQD0QVR/PWQXLXhMAAOwL/w8nUFWk176rdwAAAABJRU5ErkJggg==" alt="" />

其中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+TS4zbLeB6snQeUP8wlAKAytFPVDkwwq8s6bIbZ8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XL8mYn+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+HuD0dfrb33YUltyJf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6l/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>
密&nbsp;&nbsp;码:<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+7fePxi9PjFa3979OL1oxev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JAnais8vL0rZqim2bNjf+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小结的更多相关文章

  1. [原创]java WEB学习笔记11:HttpServlet(HttpServletRequest HttpServletRsponse) 以及关于 Servlet 小结

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

  2. Java中文编码小结

    Java中文编码小结 1. 只有 字符到字节 或者 字节到字符 的转换才存在编码转码; 2. Java String 采用 UTF-16 编码方式存储所有字符.unicode体系采用唯一的码点表示唯一 ...

  3. Java 基础--小结

    Java  基础--小结 java基础 Java源程序(.java文件)——>java字节码文件(.class文件)——>由解释执行器(java.exe)将字节码文件加载到java虚拟机( ...

  4. java servlet 几种页面跳转的方法及传值

    java servlet 几种页面跳转的方法及传值   java web 页面之间传值有一下这几种方式1.form 表单传递参数2.url地址栏传递参数3.session4.cookie5.appli ...

  5. Java Servlet与Web容器之间的关系

    自从计算机软件开发进入网络时代,就开始涉及到通讯问题.在客户/服务器(也叫C/S应用)时期,每个软件都有自己的客户端和服务器端软件.并且客户端和服务器端之间的通讯协议差别也很大.后来随着互联网的发展, ...

  6. java servlet调用带有多个返回结果集的存储过程

    一.mysql存储过程 这里我先说下我这个功能实现的逻辑及途中遇到的一些问题.这个存储过程一共带两个输入参数,一共关联到两张表的查询,每个参数都对应查询表中的一个判断,所以一共返回了两个结果集(当然要 ...

  7. java servlet+mysql全过程(原创)

    前段时间写过一篇 servlet+oracle的文章,但是那是因为公司有可能接那么一个项目,然后我当时也比较闲,所以随便学了下,那玩意是白去研究了,因为公司后面并没接到那项目. 这次学servlet用 ...

  8. java servlet+oracle 新手可看

    最近公司领导告诉接下去接的一个产品,可能会涉及到oracle数据库,以前用得最多的是mssql,前些时间学了下mysql也算少许用过.oracle没接触过.应为我之前做过.net开发,所以数据访问接口 ...

  9. Java Servlet完全教程

    Servlet 是一些遵从Java Servlet API的Java类,这些Java类可以响应请求.尽管Servlet可以响应任意类型的请求,但是它们使用最广泛的是响应web方面的请求. Servle ...

随机推荐

  1. web前端书籍

    前端开发 必看的书籍资料(转自CSDN郭小北V5) 一. html + css 这部分建议在 w3school 在线教程 上学习,边学边练,每个属性后还有在线测试. 然后过一遍之后可以模仿一些网站做些 ...

  2. WordPress基础:订阅源rss的使用

    设置->阅读,可设置rss显示效果 RSS源为:http://wordpress目录/feed 把这个地址放入你的rss阅读器进行订阅即可,最简单的就是使用QQ邮箱里面的阅读空间进行订阅.

  3. 使用SSIS汇集监控数据

    1.背景 数据库服务器部署有各类巡检脚本,现在想把巡检收集到的数据汇集到一起.Source源对应的是各业务数据库服务器,Destination目标对应的是保存汇集数据的服务器.前期部署的时候已将巡检相 ...

  4. 关于sql优化的一个小总结

    1.数据量大的时候,可以分多次查询2.有些数据的存储可以分主次表,此表存一些不常用的数据3.union all 比union效率要高4.尽量不要用distinct5.不返回不需要的行和列6.根据条件加 ...

  5. Java 使用GDAL 读写 shapefile

    读取shp文件,并把它转化为json import org.gdal.ogr.*; import org.gdal.ogr.Driver; import org.gdal.gdal.*; public ...

  6. PythonNote01_HTML标签

    >头标签<head> >>位置 头标签要放在头部之间 >>种类 <title> : 指定整个网页的标题,在浏览器最上方显示. <meta&g ...

  7. docker 使用非加密registry

    配置docker成为服务,自启动 sudo systemctl enable docker.service 启动服务 sudo systemctl start docker docker默认要求我们使 ...

  8. js 简易的分页器插件

    1.自己引入jquery插件,我的demo是引入的自己本地的query <!DOCTYPE html> <html> <head> <meta charset ...

  9. jQuery .attr("checked")得undefined 问题解决

    出现此错误是因为JQuery版本升级的问题.所以此处应该使用.prop(); 那么,什么时候使用attr(),什么时候使用prop()?1.添加属性名称该属性就会生效应该使用prop();2.是有tr ...

  10. css3(border-radius)边框圆角详解

    传统的圆角生成方案,必须使用多张图片作为背景图案.CSS3的出现,使得我们再也不必浪费时间去制作这些图片了,只需要border-radius属性,支持浏览器IE 9.Opera 10.5.Safari ...