Struts2是什么
一、概念
二、struts2的优势
1、自动封装参数 2、参数校验 3、结果的处理(转发|重定向) 4、国际化 5、显示等待页面 6、表单的防止重复提交
struts2具有更加先进的架构以及思想
三、struts2的历史
1、struts2与struts1区别就是技术上没有什么关系
2、struts2的前身时webwork框架
struts2框架搭建
一、导包
二、Action类的书写
public class HelloAction { public String hello(){ System.out.println("hello world!"); return "success"; } }
三、src/struts.xml的书写
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <package name="hello" namespace="/hello" extends="struts-default" > <action name="HelloAction" class="cn.itheima.a_hello.HelloAction" method="hello" > <result name="success" type="dispatcher" >/hello.jsp</result> </action> </package> </struts>
四、把struts2核心过滤器配置到web.xml
<!-- struts2核心过滤器 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
五、测试
六、struts2访问流程&struts2架构
AOP思想:纵向重复代码,横向抽取。