Web应用程序的执行流程?

时间:2014-03-18 05:51:21

标签: java spring jsp spring-mvc servlets

下面是我的Web应用程序的web.xml文件。我需要一个支持我的Web应用程序如何开始逐步流程。

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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/j2ee
        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
     version="2.4">

<display-name>Tudu Lists</display-name>

<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>WEB-INF/log4j.xml</param-value>
</context-param>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:META-INF/spring/application-context.xml</param-value>
</context-param>

<!-- Define the basename for a resource bundle for I18N -->
<context-param>
    <param-name>
        javax.servlet.jsp.jstl.fmt.localizationContext
    </param-name>
    <param-value>messages</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

<listener>
    <listener-class>net.sf.navigator.menu.MenuContextListener</listener-class>
</listener>

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/tudu/*</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>dwr</servlet-name>
    <servlet-class>org.directwebremoting.spring.DwrSpringServlet</servlet-class>
    <init-param>
        <param-name>debug</param-name>
        <param-value>true</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>dwr</servlet-name>
    <url-pattern>/ajax/*</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>rss</servlet-name>
    <servlet-class>tudu.web.servlet.RssFeedServlet</servlet-class>
    <load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>rss</servlet-name>
    <url-pattern>/servlet/rss</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>backup</servlet-name>
    <servlet-class>tudu.web.servlet.BackupServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>backup</servlet-name>
    <url-pattern>/servlet/tudu_lists_backup.xml</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/tudu/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/ajax/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/servlet/*</url-pattern>
</filter-mapping>

<filter>
    <filter-name>Open Session In View Filter</filter-name>
    <filter-class>
        org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
    </filter-class>
</filter>
<filter-mapping>
    <filter-name>Open Session In View Filter</filter-name>
    <url-pattern>/ajax/*</url-pattern>
</filter-mapping>

<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/tudu/*</url-pattern>
</filter-mapping>

<filter>
    <filter-name>GZipFilter</filter-name>
    <filter-class>net.sf.ehcache.constructs.web.filter.GzipFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>GZipFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
    <filter-name>SimpleCachingHeadersPageCachingFilter</filter-name>
    <filter-class>net.sf.ehcache.constructs.web.filter.SimpleCachingHeadersPageCachingFilter
    </filter-class>
    <init-param>
        <param-name>suppressStackTraces</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <param-name>cacheName</param-name>
        <param-value>web-cache</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>SimpleCachingHeadersPageCachingFilter</filter-name>
    <url-pattern>/rss</url-pattern>
</filter-mapping>

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/tudu/500</location>
</error-page>
<error-page>
    <error-code>404</error-code>
    <location>/tudu/404</location>
</error-page>

</web-app>

1 个答案:

答案 0 :(得分:5)

任何Web应用程序的流程主要基于servlets中定义的listenersweb.xml的顺序。

要了解Spring应用程序的流程,请查看Practical Use of Spring Web Flow

Practical Use of Spring Web Flow

上图是Spring文档的一部分,并说明了Spring的基本Sellitem示例的执行。 (http://docs.spring.io/spring-webflow/docs/1.0.x/reference/practical.html的第6.3节)

另请参阅此答案:https://stackoverflow.com/a/5837354/2867032

Shishir