重新梳理三大框架-----struts2之前期准备

来源:互联网 发布:电音混音软件 编辑:程序博客网 时间:2024/04/30 06:27

开发所需要的最少jar包

struts-core-2.xx.jar  struts2框架的核心类库

xwork-2.xx.jar  XWork类库,都懂的

ognl-2.xx.jar  ognl对象图导航语言 strut2框架通过其读写对象的属性

freeMarker-2.xx.jar   struts2的UI标签的模板使用freeMarker编写

commons-logging-1.xx.jar  ASF出品的日志包,struts2框架用来支持log4j和JDK1.4+的日志记录

commons-fileUpload-xx.jar  文件上传组件,2.1.6后必须加入此jar包

 

 

struts2框架是通过Filter启动的 struts1是以servlet启动

 

在web.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
 xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<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>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>
在StrutsPrepareAndExecuteFilte中的init()方法会读取类路径下默认的配置文件struts.xml完成初始化操作

 

struts2读取到struts.xml的配置后,会议javabean的形式存放在内存中,以后每次请求处理都使用内存中的数据,struts1也如此

原创粉丝点击