Struts 2中的web.xml配置文件2013-07-20 关东升 web.xml文件提供web工程部署描述信息,包含Struts2的FilterDispatcher组件配置信息,这个过滤器能够初始化Struts2框架,处理所有请求。最基本的配置方式如程序清单1.9所示。
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><filter> <filter-name>action2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>action2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping></web-app>