第1章配置开发环境( 略) 第2章 Struts 2 入门 Struts2 简介 1) Struts 是集 WebWork 和 Struts1 的新一代 MVC 设计框架。① Action 类在 Struts1 中所有 Action 类都必须继承一个抽象的 Action 类,在 Struts2 中任意的 java 对象都可以作为 Actio n 类。②线程模式 Struts1 中 Action 设计是单例模式, 也就是运行中只有一个 Action 实例,在 Struts2 中采用每个请求一个实例的设计方式, ③对 Servlet 的依赖性在 Struts 1中, Action 依赖于 Servlet API , 在 Struts2 中, 与 Servlet 相关的数据都被封装到 Map 中, Action 可以做到完全独立于 Servlet 容器。 2) 获得 Struts2 最好下载包括了所有 jar 包、文档以及源文件的 Struts2 发行包,名称为 struts-- struts 编译和运行时可能用到的组件: xwork-mons-mons-io ongl freemarker junit struts-annotations velocity velocity-tools spring testing Struts 的第一个应用 helloWrold eclipse 中构建 Str uts需自己手动导入必须的包, myeclipse 不需导入, 秩序在软件中加载即可。 Struts 2 ***需要拦截所有的用户请求, struts ***配置: < filter >< filter-name > struts2 </ filter-name > < filter-class > </ filter -class > </ filter > < filter-mapping >< filter-name > struts2 </ filter-name > < url-pattern >、* </ url-pattern > </ filter-mapping > 创建第一个 helloWord : Struts2_Helloworld_ 配置+ 详细图解首先是需要的软件和插件(可能有更新版本): struts--all : struts2 的各种 jar 文件和样例。 apache-tomcat--windows-x86 : Tomcat 服务器。 eclipse-jee-indigo-SR1-win32 : Eclipse ,注意是 Java EE 版本(因为涉及到 Web 开发) 上面 3 个在官网都有下,开源。用 MyEclipse 也可以,在 VERYCD 有下,需要破解。下面以 Eclipse 为例。打开 Eclipse ,先配置 tomcat 吧: Windows -> preferences -> Server 下拉箭头-> Runtime Environments -> Add -> 选择 tomcat -> ne
轻量级Web应用开发三大框架 来自淘豆网www.taodocs.com转载请标明出处.