在我们创建Web应用程序的时候常常用到Servlet技术而我们最常用的父类是HttpServlet
那么我们继承了这个类过后怎样生成我们所需要的模版呢?
首先我们的找到Myeclipse安装目录
如我的目录:E:\MyEclipse7.0M1\eclipse\
我们进入到:E:\MyEclipse7.0M1目录在这个目录搜索 Servlet.java 把我们不需要重新的方法和构造函数删掉...
然后修改代码如下:
#---------------------------------------------#
# <aw:description>Template for Servlet</aw:description>
# <aw:version>1.1</aw:version>
# <aw:date>04/05/2003</aw:date>
# <aw:author>Ferret Renaud</aw:author>
#---------------------------------------------#
<aw:import>java.io.IOException</aw:import>
<aw:import>java.io.PrintWriter</aw:import>
<aw:import>javax.servlet.ServletException</aw:import>
<aw:import>javax.servlet.http.HttpServlet</aw:import>
<aw:import>javax.servlet.http.HttpServletRequest</aw:import>
<aw:import>javax.servlet.http.HttpServletResponse</aw:import>
<aw:parentClass>javax.servlet.http.HttpServlet</aw:parentClass>
<aw:method name="doGet">
/**
*作者:李勇
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
</aw:method>
<aw:method name="doPost">
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet( request, response);
}
</aw:method>
</aw:method>
然后新建使用Servlet模版新建Servlet应用程序产生结果如下:
public class Myservlet extends HttpServlet {
/**
*作者:李勇
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
当然其他的修改模版都如上步骤...