-
复习 servlet 和 JSP
-
理解作用域
- 应用作用域 application
- 会话作用域 session
- 请求作用域 request
- 页面作用域 page
-
区分两个属性
-
attribute
- 主要指页面中标记 (markup) 或者标签 (tag) 中的属性
-
property
- 主要指 JavaBean 中的字段
-
Struts 中的 3 种控制器代码
- 简单验证: 通过称为 ActionForm 的 Struts 基类的子类来进行的
- 复杂验证和业务逻辑是由名为 Action 的 Struts 基类的子类来完成的
- 控制流也是由 Action 子类来决定的
-
处理业务逻辑
-
Action 的无状态性
- 一定不能在 Action 子类中保存数据
-
子类化 Action
-
覆盖 execute 方法
-
ActionForward
- 需要显示的下一个页面, 这是 execute 的返回值
-
ActionMapping
- 表示这个 Action 和其可能的下一个页面之间的关系
-
ActionForm
- 包含输入的表单信息
-
HttpServletRequest
- 包含请求范围和会话范围的数据
-
HttpServletResponse
- 允许输出数据到用户的浏览器中
-
注册 Web 应用程序中的业务逻辑
-
复杂验证
- ActionMessages
- saveErrors(request, errors)
- <html:errors property="" />
- 数据交换
-
导航
-
mapping.getInputForward()
- 获得对输入页面的引用
- mapping.findForward(...)
-
基本 Struts 标签库
- HTML
-
Bean
- 主要用于输出文本的定制标签
- 显示数据,要通过 request.setAttribute(...) 传递 Bean
-
Logic
- 提供标签来进行条件处理和循环
-
Nested
- 具有显示一个表单或者对象的"嵌套"属性的标签
-
Tiles
- 包含能够创建布局的标签
-
配置 Struts
-
表单 Bean 声明
- 将 ActionForm 子类映射到一个逻辑名
-
全局异常
- 定义在处理其间抛出的异常的处理器
-
全局转发
- 将某个页面映射到一个名字,避免了 url 硬编码
-
表单处理器
- 也称动作映射
-
控制器声明
- 配置 Struts 的内在行为,很少用到
-
消息资源
- 告诉 Struts 到哪里查找属性文件
-
插件声明
- 声明 Struts 扩展的地方,如 Tiles, Validator
-
上传文件
- <html:form enctype="multipart/form-data" action=...
- <html:file property="myFile" />
- FormFile.getInputStream()
- FormFile.destroy()
-
高级 Struts
-
Tiles
- 布局 layout
- 组件 component
- Validator 框架
- 动态表单
-
Struts 锦囊
-
PropertyUtils
- isReadable(Object bean, String property)
- isWritable(Object bean, String property)
- getPropertyType(Object bean, String property)
- setProperty(Object bean, String Property)
-
DownloadAction
- 实现 StreamInfo 接口
- 继承 DownloadAction, 覆盖 getStreamInfo()
- 在 struts-config.xml 文件配置一个表单处理器 <action >
- LocaleAction
-
IncludeAction/ForwardAction
- 处理遗留的 servlet
- LookupDispatchAction
- DispatchAction
- MappingDispatchAction
- 全局转发
- 日志
- 通配符
- 分解 struts-config.xml