MyEclipse的使用总结,修改MyEclipse默认的Servlet和jsp代码模板

一、修改Servlet的默认模板代码

使用MyEclipse创建Servlet时,根据默认的Servlet模板生成的Servlet代码如下:

 1 package gacl.servlet.study; 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 ServletDefaultTemplateCode extends HttpServlet { 12 
13     /**
14 * The doGet method of the servlet. <br> 15 * 16 * This method is called when a form has its tag value method equals to get. 17 * 18 * @param request the request send by the client to the server 19 * @param response the response send by the server to the client 20 * @throws ServletException if an error occurred 21 * @throws IOException if an error occurred 22      */
23     public void doGet(HttpServletRequest request, HttpServletResponse response) 24             throws ServletException, IOException { 25 
26         response.setContentType("text/html"); 27         PrintWriter out = response.getWriter(); 28         out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); 29         out.println("<HTML>"); 30         out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>"); 31         out.println("  <BODY>"); 32         out.print("    This is "); 33         out.print(this.getClass()); 34         out.println(", using the GET method"); 35         out.println("  </BODY>"); 36         out.println("</HTML>"); 37 out.flush(); 38 out.close(); 39 } 40 
41     /**
42 * The doPost method of the servlet. <br> 43 * 44 * This method is called when a form has its tag value method equals to post. 45 * 46 * @param request the request send by the client to the server 47 * @param response the response send by the server to the client 48 * @throws ServletException if an error occurred 49 * @throws IOException if an error occurred 50      */
51     public void doPost(HttpServletRequest request, HttpServletResponse response) 52             throws ServletException, IOException { 53 
54         response.setContentType("text/html"); 55         PrintWriter out = response.getWriter(); 56         out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); 57         out.println("<HTML>"); 58         out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>"); 59         out.println("  <BODY>"); 60         out.print("    This is "); 61         out.print(this.getClass()); 62         out.println(", using the POST method"); 63         out.println("  </BODY>"); 64         out.println("</HTML>"); 65 out.flush(); 66 out.close(); 67 } 68 
69 }

在实际开发中,这些生成的代码和注释一般我们都用不到的,每次都要手工删除这些注释和代码,很麻烦,因此可以根据开发的实际情况修改Servlet的模板代码,改成符合实际开发需求的模板代码。下面以MyEclipse 10为例进行说明如何修改Servlet的模板代码

具体步骤如下:找到MyEclipse安装目录

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值