struts2中的web.xml配置文件详解
2016-08-21 17:30
387 查看
web.xml 在Web应用程序描述符文件表示Java Web应用程序的核心,它也是Struts框架的核心的一部分。在web.xml文件中,Struts的定义其FilterDispatcher,在Servlet过滤器类初始化Struts框架和处理所有的请求。该过滤器可包含影响什么,如果有的话,额外的配置文件被加载并如何框架的行为应该初始化参数。
简单的例子:
在2.5版本以后,所有的过滤器都被移动到专用的包,例子:
在2.13以前的版本应该用,例子:
简单的例子:
<?xml version="1.0" encoding="UTF-8"?> <web-app 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_3_0.xsd" version="3.0"> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- ... --> </web-app>
在2.5版本以后,所有的过滤器都被移动到专用的包,例子:
<?xml version="1.0" encoding="UTF-8"?> <web-app 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_3_0.xsd" version="3.0"> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- ... --> </web-app>
在2.13以前的版本应该用,例子:
<?xml version="1.0" encoding="UTF-8"?> <web-app 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_3_0.xsd" version="3.0"> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- ... --> </web-app>
相关文章推荐
- web.xml配置文件详解(转)
- Struts配置文件详解,web.xml以及struts-cofig.xml,以及struts-cofig.xml中各个标签的作用
- struts2配置文件(摘录) struts2.0中struts.xml配置文件详解
- Struts2中的配置文件--web.xml文件
- struts2中struts.properties配置文件详解(及在struts.xml文件中的配置)
- web.xml配置文件详解(转)
- struts2 struts.xml配置文件详解
- struts2配置web.xml文件
- 配置Struts2 web.xml文件
- Struts配置文件详解,web.xml以及struts-cofig.xml,以及struts-cofig.xml中各个标
- 配置安装Struts2 web.xml文件
- web.xml 配置文件详解
- JSP中Web.xml配置文件详解
- Struts2配置文件详解——struts.xml
- web.xml配置文件详解(转)
- web.xml配置文件详解(转)
- [转]Struts配置文件详解,web.xml以及struts-cofig.xml,以及struts-cofig.xml中各个标签的作用。
- web.xml配置文件详解(转)
- J2EE项目web.xml文件中Struts2配置错误
- struts2的web.xml文件配置