Servlet开发之继承GenericServlet
2016-02-20 本文已影响75人
onweer
继承GenericServlet
package com.lee;
import javax.servlet.GenericServlet;
import javax.servlet.*;
import java.io.*;
public class GenericDemo extends GenericServlet{
// 重写Service方法
public void service (ServletRequest req,ServletResponse res){
try{
PrintWriter pw = res.getWriter();
pw.println("Hello world! genneric");
}catch(Exception e){
e.printStackTrace();
}
}
}
XML配置文件:
<servlet>
<servlet-name>genericDemo</servlet-name>
<servlet-class>com.lee.GenericDemo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>genericDemo</servlet-name>
<url-pattern>/gen</url-pattern>
</servlet-mapping>
给个github follow me的链接,上面有很多初学者可供学习的资料,项目.
https://github.com/SuperZee