Java 应用系统开发 - ServletContext 和 Web 配置# Java 应用系统开发 ServletContext 和 Web 配置 王晓东 wangxiaodong@ouc.edu.cn 中国海洋大学 November 26, 2018  ,并将 Web 应用的基本信息存储在这个 ServletContext 对象中。 ## Web 应用环境对象的用途 所有 Web 组件都可以访问此 ServletContext 对象,进而取得 Web 应用的基本信息。 ▶ ServletContext 还可以作为整个 Web 应用的共享容器对象,能够被所有会话请求共用,保存0 码力 | 33 页 | 668.91 KB | 2 年前3
Java 应用与开发 - Java EE 监听器编程掌握监听器的编程和配置,学会编写监听器代码。 ## 大纲 监听器概述 Java EE 监听器类型 ServletContext 对象监听器 ServletContext 对象属性监听器 本节习题 接下来… 监听器概述 Java EE 监听器类型 ServletContext 对象监听器 ServletContext 对象属性监听器 本节习题 ## 什么是监听器 监听器,顾名思义就是能监测其他对象 法,完成特定的功能和任务。Java EE 规范在 Servlet 2.3 中引入了监听器(Listener)规范。 Java EE 监听器能够检测 Web 应用的关键对象包括: ▶ ServletContext 上下文 ▶ HttpSession 会话 ▶ ServletRequest 请求对象 ## 监听器的应用场景 ## ▶ 网站访问人数或次数计数器 访问人数计数是所有综合门户网站 ## 会话超时后的清理工作 接下来… 监听器概述 Java EE 监听器类型 ServletContext 对象监听器 ServletContext 对象属性监听器 本节习题 ## Java EE 监听器类型 1. ServletContext 对象监听器 2. ServletContext 对象属性监听器 3. HttpSession 对象监听器 4. HttpSession0 码力 | 22 页 | 549.84 KB | 2 年前3
手写Tomcat 廖雪峰 2025-06-16com/books/jerrymouse/ 目录 简介 设计服务器架构 Servlet规范 实现HTTP服务器 实现Servlet服务器 实现Servlet组件 6.1. 实现ServletContext 6.2. 实现FilterChain 6.3. 实现HttpSession 6.4. 实现Listener 加载Web App 7.1. 实现ClassLoader 7.2. 部署Web Servlet组件完成HTTP处理,将响应写入 HttpServletResponse 对象: 其中,ServletContext 代表整个容器的信息,如果容器实现了 ServletContext 接口,也可以把 ServletContext 可以看作容器本身。ServletContext 、 HttpServletRequest 和 HttpServletResponse 都是接口,具体实现由Web服务器完成。Filter 都是运行在容器中的组件,只有容器才能主动调用它们。(此处略去JSP组件,因为我们不打算支持JSP) 对于Jerrymouse服务器来说,开发服务器就必须实现Servlet容器本身,容器实现 ServletContext 接口,容器内部管理若干个 Servlet 、 Filter 和 Listener 组件。 对每个请求,需要创建 HttpServletRequest 和 HttpServletResponse0 码力 | 75 页 | 2.14 MB | 26 天前3
《Java 应用与开发》课程讲义 - 王晓东248 19.4.5 会话 ID 的保存方式 ..... 248 19.4.6 会话对象的应用示例 ..... 248 19.5 课后习题 ..... 250 20 ServletContext 和 Web 配置 ..... 251 20.1 Web 应用环境对象 ..... 252 20.1.1 Web 应用环境对象 ..... 252 20.1.2 Web 应用环境对象的生命周期 监听器编程 ..... 271 22.1 监听器概述 ..... 272 22.2 Java EE 监听器类型 ..... 272 22.3 ServletContext 对象监听器 ..... 273 22.4 ServletContext 对象属性监听器 ..... 275 22.5 课后习题 ..... 276 23 JSP(Java Server Page) ..... 277 以使外界能够获取该类的实例,达到全局可见的效果。 在任何使用到 Single 类的 Java 程序中(这里指的是一次运行中),需要确保只有一个 Single 类的实例存在(如 Web 应用 ServletContext 全局上下文对象),则使用该模式。 ### 5.4 关键字 final 在声明 Java 类、变量和方法时可以使用关键字 final 来修饰,以使其具有 “终态” 的特性: 1. final0 码力 | 330 页 | 6.54 MB | 2 年前3
手写Spring 廖雪峰 2025-06-16dispatcherServlet = new DispatcherServlet(); // 注册DispatcherServlet: var dispatcherReg = servletContext.addServlet("dispatcherServlet", dispatcherServlet); dispatcherReg.addMapping("/"); 在 ContextLoaderListener 的 contextInitialized() 方法内,先获取 ServletContext 引用,再通过 getInitParameter(“configuration”) 拿到完整类名,就可以顺利创建IoC容器了。 用Maven打包后,把生成的 xyz.war 改为 ROOT final String templateEncoding; final ServletContext servletContext; Configuration config; public FreeMarkerViewResolver(ServletContext servletContext, String templatePath, String templateEncoding)0 码力 | 109 页 | 3.16 MB | 26 天前3
Spring Boot 2.0.8.RELEASE Reference Guideembedded in an environment variable or system property). 6. ServletConfig init parameters. 7. ServletContext init parameters. 8. JNDI attributes from java:comp/env. 9. Java System properties (System.properties/) /static (or /public or /resources or /META-INF/resources) in the classpath or from the root of the ServletContext. It uses the ResourceHttpRequestHandler from Spring MVC so that you can modify that behavior from the container is also enabled and acts as a fallback, serving content from the root of the ServletContext if Spring decides not to handle it. Most of the time, this does not happen (unless you modify0 码力 | 662 页 | 634.14 KB | 2 年前3
Spring Boot 2.1.0.M4 Reference Guideembedded in an environment variable or system property). 6. ServletConfig init parameters. 7. ServletContext init parameters. 8. JNDI attributes from java:comp/env. 9. Java System properties (System.properties/) /static (or /public or /resources or /META-INF/resources) in the classpath or from the root of the ServletContext. It uses the ResourceHttpRequestHandler from Spring MVC so that you can modify that behavior from the container is also enabled and acts as a fallback, serving content from the root of the ServletContext if Spring decides not to handle it. Most of the time, this does not happen (unless you modify0 码力 | 680 页 | 643.09 KB | 2 年前3
Spring Framwork Web on Servlet Stack v5.3.36 SNAPSHOTMyWebApplicationInitialize implements WebApplicationInitialize { @Override public void onStartup(ServletContext serviceContext) { // Load Spring web application configuration AnnotationCo } ## Kotlin class MyWebApplication年初: WebApplication年初 { override fun onStartup(servletContext: ServletContext) { // Load Spring web application configuration val context = Annota the DispatcherServlet valservlet = DispatcherServlet(context) valregistration =servletContext.addServlet("app",servlet) registration.setLoadOnStartup(1) registration0 码力 | 259 页 | 3.58 MB | 2 年前3
Spring Framework 1.2.x Changelog* added overloaded constructors to MockFilterConfig, using a MockServletContext instead of a ServletContext argument Package org.springframework.orm * refined JDO PersistenceManagerFactoryUtils to explicitly even after a forward/include * added various RequestLoggingFilters: for Commons Logging, the ServletContext log, and Log4J including NDC support * FrameworkServlet exposes protected "processRequest" Log4jConfigListener/Servlet supports "file:" URL as "log4jConfigLocation" (as alternative to ServletContext resource) * Log4jConfigListener/Servlet and WebAppRootListener remove the web app root system0 码力 | 94 页 | 267.57 KB | 2 年前3
Spring Framework 1.1.5 ChangelogLog4jConfigListener/Servlet supports "file:" URL as "log4jConfigLocation" (as alternative to ServletContext resource) * Log4jConfigListener/Servlet and WebAppRootListener remove the web app root system ServletContextFactoryBean, exposing the ServletContext for bean references (alternative to ServletContextAware) * added ServletContextAttributeFactoryBean, exposing an existing ServletContext attribute for bean references references * added ServletContextAttributeExporter, taking Spring-defined objects and exposing them as ServletContext attributes * added ServletContextPropertyPlaceholderConfigurer, a subclass that falls back to0 码力 | 57 页 | 166.71 KB | 2 年前3
共 325 条
- 1
- 2
- 3
- 4
- 5
- 6
- 33
相关搜索词
ServletContextWeb 配置ServletConfigWeb 环境对象会话超时Java EE 监听器ServletContext 监听器HttpSession 会话ServletContext 对象属性监听器ServletRequest 请求对象手写Tomcat雪峰20250616Java应用与开发ServletJava EE线程异常处理SpringSpring BootSpring Framework嵌入式 Servlet ContainersMavenGradleSpring Boot CLI启动器Spring Web MVCDispatcherServletWebSocketFilterContextLoaderListenerAOPBeanFactoryTransaction ManagementJDBCJMSVelocityViewResolverHibernateTemplateAbstractBeanFactoryAOP框架事务管理视图解析器













