• 修改Servlet&JSP模板


    1. common/plugins/com.genuitec.eclipse.wizards.xxx.jar ---- 都是zip格式的
    2. 打开Jar包中的Templates文件夹既可以看到Servlet.java源代码,直接修改就可以了
    3. 修改好之后保存
    4. 重新启动Myeclipse即可以使用新的模板代码了

    我的地址:D:ProgramFilesMyEclipseCommonpluginscom.genuitec.eclipse.wizards_9.0.0.me201211011550.jar

    修改JSP:Templates --->jsp--->Jsp.vtl

    修改后的Servlet

    #---------------------------------------------#
    # <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:constructor name="c1">
        /**
         * Constructor of the object.
         */
        public <aw:className/>() {
            super();
        }
    
    </aw:constructor> 
     
    <aw:method name="doGet">
        /**
         * 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 {
    
        }
    
    </aw:method>
    
    <aw:method name="doPost">
        /**
         * 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 {
                doGet(request,response);
        }
    
    </aw:method>
    
    <aw:method name="doPut">
        /**
         * The doPut method of the servlet. <br>
         *
         * This method is called when a HTTP put request is received.
         * 
         * @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 doPut(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
    
            // Put your code here
        }
    
    </aw:method>
    
    <aw:method name="doDelete">
        /**
         * The doDelete method of the servlet. <br>
         *
         * This method is called when a HTTP delete request is received.
         * 
         * @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 doDelete(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
    
            // Put your code here
        }
    
    </aw:method>
    
    <aw:method name="init">
        /**
         * Initialization of the servlet. <br>
         *
         * @throws ServletException if an error occurs
         */
        public void init() throws ServletException {
            // Put your code here
        }
    
    </aw:method>
    
    <aw:method name="destroy">
        /**
         * Destruction of the servlet. <br>
         */
        public void destroy() {
            super.destroy(); // Just puts "destroy" string in log
            // Put your code here
        }
    
    </aw:method>
    
    <aw:method name="getServletInfo">
        /**
         * Returns information about the servlet, such as 
         * author, version, and copyright. 
         *
         * @return String information about this servlet
         */
        public String getServletInfo() {
            return "This is my default servlet created by Eclipse";
        }
    
    </aw:method>

    修改后的JSP:

    #*---------------------------------------------#
    # Template for a JSP
    # @version: 1.2
    # @author: Ferret Renaud
    # @author: Jed Anderson
    #---------------------------------------------#
    *#<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Insert title here</title>
      </head>
      
      <body>
        
      </body>
    </html>
  • 相关阅读:
    (一)Python入门-4控制语句:07嵌套循环-练习
    (一)Python入门-4控制语句:06for循环结构-遍历各种可迭代对象-range对象
    (一)Python入门-4控制语句:05while循环结构-死循环处理
    (一)Python入门-4控制语句:04多分支选择结构-选择结构的嵌套
    Java学习第三章 之 基础语法
    Java学习第二章 之 变量、数据类型和运算符
    Java学习第一章 之 初识Java
    JavaScrip学习笔记_JS中的foreach
    链接自动跟随光标
    LeetCode刷题记录_38. 报数
  • 原文地址:https://www.cnblogs.com/vaer/p/3913441.html
Copyright © 2020-2023  润新知