• java-servlet 新增特性 注释


    package com.gordon.servlet;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebInitParam;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    /**
     * Servlet implementation class TestAjax
     */
    @WebServlet(name = "testservlet",
                urlPatterns = { "/testservlet1", "/testservlet2" },
                initParams = { @WebInitParam(name = "name", value = "value1"),
                               @WebInitParam(name="name1", value="value2")})
    public class TestAjax extends HttpServlet {
        
        private String name;
        private String name1;
        
        private static final long serialVersionUID = 1L;
    
        public TestAjax() {
            super();
        }
    
        public void init(ServletConfig config) throws ServletException {
            // TODO Auto-generated method stub
            this.name = config.getInitParameter("name");
            this.name1 = config.getInitParameter("name1");
        }
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            PrintWriter pw = response.getWriter();
            pw.append("Served at: ").append(request.getContextPath());
            pw.append("--------------------");
            pw.append(this.name);
            pw.append("--------------------");
            pw.append(this.name1);
        }
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            doGet(request, response);
        }
    }
  • 相关阅读:
    JAVA BASE64
    Mysql Index extends优化
    JAVA异步加回调的例子
    TCP长连接和短连接的区别
    浅析RPC概念框架
    MySQL Index Merge Optimization
    一简单的RPC实例(Java)
    return语句的用法
    java中对象和对象的引用
    UML中几种类间关系:继承、实现、依赖、关联、聚合、组合的联系与区别
  • 原文地址:https://www.cnblogs.com/hfultrastrong/p/7261799.html
Copyright © 2020-2023  润新知