如何在myeclipse中更改servlet模板

本来想原创,看到有很多人已经写了,所以别人做过的就“拿来主义”了


原Servlet模板实例

[html]  view plain copy
  1. <span style="font-size:18px">package www.csdn.net.servlet;  
  2.   
  3. import java.io.IOException;  
  4. import java.io.PrintWriter;  
  5.   
  6. import javax.servlet.ServletException;  
  7. import javax.servlet.http.HttpServlet;  
  8. import javax.servlet.http.HttpServletRequest;  
  9. import javax.servlet.http.HttpServletResponse;  
  10.   
  11. public class First extends HttpServlet {  
  12.   
  13.     /**  
  14.      * Constructor of the object.  
  15.      */  
  16.     public First() {  
  17.         super();  
  18.     }  
  19.   
  20.     /**  
  21.      * Destruction of the servlet. <br>  
  22.      */  
  23.     public void destroy() {  
  24.         super.destroy(); // Just puts "destroy" string in log  
  25.         // Put your code here  
  26.     }  
  27.   
  28.     /**  
  29.      * The doGet method of the servlet. <br>  
  30.      *  
  31.      * This method is called when a form has its tag value method equals to get.  
  32.      *   
  33.      * @param request the request send by the client to the server  
  34.      * @param response the response send by the server to the client  
  35.      * @throws ServletException if an error occurred  
  36.      * @throws IOException if an error occurred  
  37.      */  
  38.     public void doGet(HttpServletRequest request, HttpServletResponse response)  
  39.             throws ServletException, IOException {  
  40.   
  41.         response.setContentType("text/html");  
  42.         PrintWriter out = response.getWriter();  
  43.         out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");  
  44.         out.println("<HTML>");  
  45.         out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");  
  46.         out.println("  <BODY>");  
  47.         out.print("    This is ");  
  48.         out.print(this.getClass());  
  49.         out.println(", using the GET method");  
  50.         out.println("  </BODY>");  
  51.         out.println("</HTML>");  
  52.         out.flush();  
  53.         out.close();  
  54.     }  
  55.   
  56.     /**  
  57.      * The doPost method of the servlet. <br>  
  58.      *  
  59.      * This method is called when a form has its tag value method equals to post.  
  60.      *   
  61.      * @param request the request send by the client to the server  
  62.      * @param response the response send by the server to the client  
  63.      * @throws ServletException if an error occurred  
  64.      * @throws IOException if an error occurred  
  65.      */  
  66.     public void doPost(HttpServletRequest request, HttpServletResponse response)  
  67.             throws ServletException, IOException {  
  68.   
  69.         response.setContentType("text/html");  
  70.         PrintWriter out = response.getWriter();  
  71.         out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");  
  72.         out.println("<HTML>");  
  73.         out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");  
  74.         out.println("  <BODY>");  
  75.         out.print("    This is ");  
  76.         out.print(this.getClass());  
  77.         out.println(", using the POST method");  
  78.         out.println("  </BODY>");  
  79.         out.println("</HTML>");  
  80.         out.flush();  
  81.         out.close();  
  82.     }  
  83.   
  84.     /**  
  85.      * Initialization of the servlet. <br>  
  86.      *  
  87.      * @throws ServletException if an error occurs  
  88.      */  
  89.     public void init() throws ServletException {  
  90.         // Put your code here  
  91.     }  
  92.   
  93. }  
  94. </span>  


 

怎样在建Servlet时去掉所有的注释:

先找到MyEclipse安装到哪

(1)右击MyEclipse

(2)复制目标(T)的路径,然后粘在计算机路径下进行搜索

 

(3)点击plugins文件

 

(4)搜寻这个文件

(5)打开文件找模版templates在template下再找servlet.java

(6)打开servlet.java在里面删除所有的注解

 

(7)在重新启动工具MyEclipse(注),在建一个新的servlet文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值