• Servlet随笔


    HttpServlet中的getRequestURL、getRequestURI、getContextPath方法获取的字符串为

    jsp文件会被编译成一个Servlet,该Servlet继承自HttpJspBase,该Servlet中的_jspService方法的部分代码如下

    login.jsp被编译成login_jsp类

     HttpJspPage接口中的方法如下

    抽象类HttpJspBase实现了HttpJspPage接口

    package org.apache.jasper.runtime;
    
    import java.io.IOException;
    
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.jsp.HttpJspPage;
    
    import org.apache.jasper.compiler.Localizer;
    
    public abstract class HttpJspBase extends HttpServlet implements HttpJspPage {
        
        private static final long serialVersionUID = 1L;
    
        protected HttpJspBase() {
        }
    
        @Override
        public final void init(ServletConfig config) 
            throws ServletException 
        {
            super.init(config);
            jspInit();
            _jspInit();
        }
        
        @Override
        public String getServletInfo() {
            return Localizer.getMessage("jsp.engine.info");
        }
    
        @Override
        public final void destroy() {
            jspDestroy();
            _jspDestroy();
        }
        @Override
        public final void service(HttpServletRequest request, HttpServletResponse response) 
            throws ServletException, IOException 
        {
            _jspService(request, response);
        }
        
        @Override
        public void jspInit() {
        }
    
        public void _jspInit() {
        }
    
        @Override
        public void jspDestroy() {
        }
    
        protected void _jspDestroy() {
        }
    
        @Override
        public abstract void _jspService(HttpServletRequest request, 
                                         HttpServletResponse response) 
            throws ServletException, IOException;
    }
    

      

  • 相关阅读:
    图片加载库Glide
    Home键和back键下 Activity的生命周期变化
    Fragment重叠问题
    Fragment与Activiy之间的交互
    android事件拦截处理机制详解 .--------转
    实现手机QQ的抖动效果
    点评点赞功能的基本实现------个人观点
    自定义侧滑菜单
    检查设备剩余内存
    StringByAppendingPathComponent和stringByAppendingString的区别
  • 原文地址:https://www.cnblogs.com/xiu68/p/8675022.html
Copyright © 2020-2023  润新知