JavaWeb第5章:JSP语法元素与页面生命周期详解

需积分: 9 0 下载量 24 浏览量 更新于2024-07-13 收藏 174KB PPT 举报
JavaWeb编程技术是基于Java平台的网络应用开发技术,第5章主要聚焦于JSP(JavaServer Pages)技术,这是一种动态网页技术,用于将服务器端的Java代码嵌入到HTML中,实现页面内容的动态生成。本章涵盖了以下几个核心知识点: 1. **JSP语法元素**: - JSP指令(<%@ 指令 %>):用于向容器发送转换时的指令,如设置页面编码或内容类型。 - JSP声明(<%! ... %>):用于在JSP页面中声明变量和方法,如同Java程序中的预编译声明部分,例如声明数组和方法定义。 - 小脚本(<% ... %>):允许开发者编写自由格式的Java代码,执行简单的逻辑或操作。 - JSP表达式(<%= ... %>):用于在页面输出中快速插入变量值,类似于Java的运算符。 - JSP动作(<jsp:动作名 />):提供请求时向容器发送的指令,如包括其他页面或执行特定服务。 - EL表达式(${expression}):JSP 2.0引入的简化版表达式语言,用于更简洁地引用Java对象属性。 2. **JSP页面生命周期**:详细解释了JSP页面从加载、执行到销毁的过程,涉及初始化、服务请求、响应阶段等关键步骤。 3. **页面转换过程**:讲解JSP如何被服务器接收、解析、执行Java代码并生成HTML响应的过程。 4. **JSP隐含变量**:介绍页面范围内的默认变量,如request、response、session等,它们在JSP页面中可以直接使用。 5. **JSP页面作用域**:讨论不同类型的页面作用域,如page、request、session和application,以及它们对数据存储的影响。 6. **JSP页面元素分类**:通过表格形式列出JSP页面的元素类型,如标签(标签语法)、脚本元素(声明、小脚本和表达式)以及注释。 7. **实例分析**:通过一个名为counter.jsp的简单示例,展示了声明变量、使用小脚本计数器以及输出页面访问次数的过程,直观展示了这些概念的运用。 第5章JSP是JavaWeb开发的核心内容,深入理解这些元素和概念对于构建动态网页至关重要,它涉及到了页面的编写、执行和交互流程,以及如何利用Java的强大功能为用户提供灵活且高效的网络应用体验。

我用Spring5的aop应用时报这个错误Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [D:\ecliple\web5\WEB-INF\applicationContext.xml]; nested exception is java.nio.file.NoSuchFileException: WEB-INF\applicationContext.xml,他说我的applicationContext.xml文件不存在,可是我明明有这个文件,另外我的web.xml需要更改吗<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <context-param> <param-name>contextConfigLocation </param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <display-name>Struts2</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter> <filter-name>OpenSessionInViewFilter</filter-name> <filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>OpenSessionInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/* </url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> </web-app>

2023-05-30 上传