SpringMVC的web.xml配置詳解

spring是目前最流行的框架。創(chuàng)建java web項(xiàng)目時(shí),我們首先會(huì)遇到的配置文件就是web.xml,這是javaweb為我們封裝的邏輯,不在今天的研究中。下面我們將簡(jiǎn)單講講web.xml中的配置。

創(chuàng)新互聯(lián)建站專注于莫力達(dá)企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站建設(shè),成都商城網(wǎng)站開(kāi)發(fā)。莫力達(dá)網(wǎng)站建設(shè)公司,為莫力達(dá)等地區(qū)提供建站服務(wù)。全流程按需設(shè)計(jì),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務(wù)

一、一個(gè)空的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  id="WebApp_ID">
</web-app>

二、標(biāo)簽介紹

web.xml中比較常見(jiàn)的標(biāo)簽以及其加載順序?yàn)椋?/p>

context-param > listener > filter > servlet

1、 <display-name>Archetype Created Web Application</display-name>

display-name 是標(biāo)識(shí)項(xiàng)目的名稱,這個(gè)不是很常用,可有可無(wú)的,或者說(shuō)不需要我們?nèi)ピ谝獾臇|西。

2、 <context-param>

<context-param>
  <param-name>webAppRootKey</param-name>
  <param-value>60000</param-value>
</context-param>

context-param 是web.xml首先加載的標(biāo)簽,其下子標(biāo)簽有param-name和param-value.

此所設(shè)定的參數(shù),在JSP網(wǎng)頁(yè)中可以使用下列方法來(lái)取得:

${initParam.webAppRootKey}

若在Servlet可以使用下列方法來(lái)獲得:

復(fù)制代碼 代碼如下:

String param_name=getServletContext().getInitParamter(“webAppRootKey”);

Spring MVC的web.xml配置詳解

3、listener

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

listenter在項(xiàng)目開(kāi)始的時(shí)候就注入進(jìn)來(lái),盡在context-param之后,所以正常我們將spring配置在listener 中,這樣方法spring 初始化相關(guān)的bean。

4、filter

<filter>
    <filter-name>CharacterEncodingFilter</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>CharacterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

filter起到一個(gè)過(guò)濾的作用,在servlet執(zhí)行前后,像上面的配置就是在過(guò)濾servlet前將編碼轉(zhuǎn)換UTF-8,filter-mapping 則是將filter和url路徑進(jìn)行映射。其中init-param則是將初始化需要的參數(shù)傳入到filter-class中從而進(jìn)行初始化。filter和filter-mapping中的name必須是相同的,才能起到映射的作用,而filter-mapping 中的url-pattern則是匹配請(qǐng)求路徑的。上面‘/*'表示過(guò)濾所有請(qǐng)求的servlet,如果寫(xiě)成‘/zxh',則過(guò)濾http://localhost:8080/項(xiàng)目名/zxh這個(gè)請(qǐng)求。

5、servlet

  <servlet> 
    <!-- 配置DispatcherServlet --> 
    <servlet-name>springMvc</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
      <!-- 指定spring mvc配置文件位置 不指定使用默認(rèn)情況 --> 
      <init-param>   
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring/spring-mvc.xml</param-value>
      </init-param> 
    <!-- 設(shè)置啟動(dòng)順序 --> 
    <load-on-startup>1</load-on-startup> 
  </servlet>

  <!-- ServLet 匹配映射 -->
  <servlet-mapping>
    <servlet-name>springMvc</servlet-name>
    <url-pattern>*.zxh</url-pattern>
  </servlet-mapping>

servlet和filter類似,需要先指定servlet對(duì)應(yīng)的class類,然后將這個(gè)類和utl路徑請(qǐng)求地址進(jìn)行映射。這里不多說(shuō)了。

以上就是web.xml文件中出現(xiàn)最多的幾個(gè)標(biāo)簽。其他的比如:

6、歡迎頁(yè)

<welcome-file-list>
    <welcome-file>login.jsp</welcome-file>
  </welcome-file-list>

7、錯(cuò)誤頁(yè)

  <!-- 后臺(tái)程序異常錯(cuò)誤跳轉(zhuǎn)頁(yè)面 -->
  <error-page> 
    <exception-type>java.lang.Throwable</exception-type> 
    <location>/views/error.jsp</location> 
  </error-page> 

  <!-- 500跳轉(zhuǎn)頁(yè)面-->
  <error-page> 
    <error-code>500</error-code> 
    <location>/views/500.jsp</location> 
  </error-page> 

  <!-- 404跳轉(zhuǎn)頁(yè)面 -->
  <error-page> 
    <error-code>404</error-code> 
    <location>/views/404.jsp</location> 
  </error-page>

三、示例

1、spring 框架解決字符串編碼問(wèn)題:過(guò)濾器 CharacterEncodingFilter(filter-name)

2、在web.xml配置監(jiān)聽(tīng)器ContextLoaderListener(listener-class)
ContextLoaderListener的作用就是啟動(dòng)Web容器時(shí),自動(dòng)裝配ApplicationContext的配置信息。因?yàn)樗鼘?shí)現(xiàn)了ServletContextListener這個(gè)接口,在web.xml配置這個(gè)監(jiān)聽(tīng)器,啟動(dòng)容器時(shí),就會(huì)默認(rèn)執(zhí)行它實(shí)現(xiàn)的方法。

3、部署applicationContext的xml文件:contextConfigLocation(context-param下的param-name)

4、DispatcherServlet是前置控制器,配置在web.xml文件中的。攔截匹配的請(qǐng)求,Servlet攔截匹配規(guī)則要自已定義,把攔截下來(lái)的請(qǐng)求,依據(jù)某某規(guī)則分發(fā)到目標(biāo)Controller(我們寫(xiě)的Action)來(lái)處理。

DispatcherServlet(servlet-name、servlet-class、init-param、param-name(contextConfigLocation)、param-value)
在DispatcherServlet的初始化過(guò)程中,框架會(huì)在web應(yīng)用的 WEB-INF文件夾下尋找名為[servlet-name]-servlet.xml 的配置文件,生成文件中定義的bean

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="3.0" 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"> 

  <!-- 在Spring框架中是如何解決從頁(yè)面?zhèn)鱽?lái)的字符串的編碼問(wèn)題的呢?
  下面我們來(lái)看看Spring框架給我們提供過(guò)濾器CharacterEncodingFilter 
   這個(gè)過(guò)濾器就是針對(duì)于每次瀏覽器請(qǐng)求進(jìn)行過(guò)濾的,然后再其之上添加了父類沒(méi)有的功能即處理字符編碼。 
   其中encoding用來(lái)設(shè)置編碼格式,forceEncoding用來(lái)設(shè)置是否理會(huì) request.getCharacterEncoding()方法,設(shè)置為true則強(qiáng)制覆蓋之前的編碼格式。--> 
  <filter> 
    <filter-name>characterEncodingFilter</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>characterEncodingFilter</filter-name> 
    <url-pattern>/*</url-pattern> 
  </filter-mapping> 
  <!-- 項(xiàng)目中使用Spring 時(shí),applicationContext.xml配置文件中并沒(méi)有BeanFactory,要想在業(yè)務(wù)層中的class 文件中直接引用Spring容器管理的bean可通過(guò)以下方式--> 
  <!--1、在web.xml配置監(jiān)聽(tīng)器ContextLoaderListener--> 
  <!--ContextLoaderListener的作用就是啟動(dòng)Web容器時(shí),自動(dòng)裝配ApplicationContext的配置信息。因?yàn)樗鼘?shí)現(xiàn)了ServletContextListener這個(gè)接口,在web.xml配置這個(gè)監(jiān)聽(tīng)器,啟動(dòng)容器時(shí),就會(huì)默認(rèn)執(zhí)行它實(shí)現(xiàn)的方法。 
  在ContextLoaderListener中關(guān)聯(lián)了ContextLoader這個(gè)類,所以整個(gè)加載配置過(guò)程由ContextLoader來(lái)完成。 
  它的API說(shuō)明 
  第一段說(shuō)明ContextLoader可以由 ContextLoaderListener和ContextLoaderServlet生成。 
  如果查看ContextLoaderServlet的API,可以看到它也關(guān)聯(lián)了ContextLoader這個(gè)類而且它實(shí)現(xiàn)了HttpServlet這個(gè)接口 
  第二段,ContextLoader創(chuàng)建的是 XmlWebApplicationContext這樣一個(gè)類,它實(shí)現(xiàn)的接口是WebApplicationContext->ConfigurableWebApplicationContext->ApplicationContext-> 
  BeanFactory這樣一來(lái)spring中的所有bean都由這個(gè)類來(lái)創(chuàng)建 
   IUploaddatafileManager uploadmanager = (IUploaddatafileManager)  ContextLoaderListener.getCurrentWebApplicationContext().getBean("uploadManager");
   --> 
  <listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
  </listener> 
  <!--2、部署applicationContext的xml文件--> 
  <!--如果在web.xml中不寫(xiě)任何參數(shù)配置信息,默認(rèn)的路徑是"/WEB-INF/applicationContext.xml, 
  在WEB-INF目錄下創(chuàng)建的xml文件的名稱必須是applicationContext.xml。 
  如果是要自定義文件名可以在web.xml里加入contextConfigLocation這個(gè)context參數(shù): 
  在<param-value> </param-value>里指定相應(yīng)的xml文件名,如果有多個(gè)xml文件,可以寫(xiě)在一起并以“,”號(hào)分隔。 
  也可以這樣applicationContext-*.xml采用通配符,比如這那個(gè)目錄下有applicationContext-ibatis-base.xml, 
  applicationContext-action.xml,applicationContext-ibatis-dao.xml等文件,都會(huì)一同被載入。 
  在ContextLoaderListener中關(guān)聯(lián)了ContextLoader這個(gè)類,所以整個(gè)加載配置過(guò)程由ContextLoader來(lái)完成。--> 
  <context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>classpath:spring/applicationContext.xml</param-value> 
  </context-param> 

  <!--如果你的DispatcherServlet攔截"/",為了實(shí)現(xiàn)REST風(fēng)格,攔截了所有的請(qǐng)求,那么同時(shí)對(duì)*.js,*.jpg等靜態(tài)文件的訪問(wèn)也就被攔截了。--> 
  <!--方案一:激活Tomcat的defaultServlet來(lái)處理靜態(tài)文件--> 
  <!--要寫(xiě)在DispatcherServlet的前面, 讓 defaultServlet先攔截請(qǐng)求,這樣請(qǐng)求就不會(huì)進(jìn)入Spring了,我想性能是最好的吧。--> 
  <servlet-mapping> 
    <servlet-name>default</servlet-name> 
    <url-pattern>*.css</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>default</servlet-name> 
    <url-pattern>*.swf</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>default</servlet-name> 
    <url-pattern>*.gif</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>default</servlet-name> 
    <url-pattern>*.jpg</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>default</servlet-name> 
    <url-pattern>*.png</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>default</servlet-name> 
    <url-pattern>*.js</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>default</servlet-name> 
    <url-pattern>*.html</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>default</servlet-name> 
    <url-pattern>*.xml</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>default</servlet-name> 
    <url-pattern>*.json</url-pattern> 
  </servlet-mapping> 
  <servlet-mapping> 
    <servlet-name>default</servlet-name> 
    <url-pattern>*.map</url-pattern> 
  </servlet-mapping> 
  <!--使用Spring MVC,配置DispatcherServlet是第一步。DispatcherServlet是一個(gè)Servlet,,所以可以配置多個(gè)DispatcherServlet--> 
  <!--DispatcherServlet是前置控制器,配置在web.xml文件中的。攔截匹配的請(qǐng)求,Servlet攔截匹配規(guī)則要自已定義,把攔截下來(lái)的請(qǐng)求,依據(jù)某某規(guī)則分發(fā)到目標(biāo)Controller(我們寫(xiě)的Action)來(lái)處理。--> 
  <servlet> 
    <servlet-name>DispatcherServlet</servlet-name><!--在DispatcherServlet的初始化過(guò)程中,框架會(huì)在web應(yīng)用的 WEB-INF文件夾下尋找名為[servlet-name]-servlet.xml 的配置文件,生成文件中定義的bean。--> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    <!--指明了配置文件的文件名,不使用默認(rèn)配置文件名,而使用dispatcher-servlet.xml配置文件。--> 
    <init-param> 
      <param-name>contextConfigLocation</param-name> 
      <!--其中<param-value>**.xml</param-value> 這里可以使用多種寫(xiě)法--> 
      <!--1、不寫(xiě),使用默認(rèn)值:/WEB-INF/<servlet-name>-servlet.xml--> 
      <!--2、<param-value>/WEB-INF/classes/dispatcher-servlet.xml</param-value>--> 
      <!--3、<param-value>classpath*:dispatcher-servlet.xml</param-value>--> 
      <!--4、多個(gè)值用逗號(hào)分隔--> 
      <param-value>classpath:spring/dispatcher-servlet.xml</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup><!--是啟動(dòng)順序,讓這個(gè)Servlet隨Servletp容器一起啟動(dòng)。--> 
  </servlet> 
  <servlet-mapping> 
    <!--這個(gè)Servlet的名字是dispatcher,可以有多個(gè)DispatcherServlet,是通過(guò)名字來(lái)區(qū)分的。每一個(gè)DispatcherServlet有自己的WebApplicationContext上下文對(duì)象。同時(shí)保存的ServletContext中和Request對(duì)象中.--> 
    <!--ApplicationContext是Spring的核心,Context我們通常解釋為上下文環(huán)境,我想用“容器”來(lái)表述它更容易理解一些,ApplicationContext則是“應(yīng)用的容器”了:P,Spring把Bean放在這個(gè)容器中,在需要的時(shí)候,用getBean方法取出--> 
    <servlet-name>DispatcherServlet</servlet-name> 
    <!--Servlet攔截匹配規(guī)則可以自已定義,當(dāng)映射為@RequestMapping("/user/add")時(shí),為例,攔截哪種URL合適?--> 
    <!--1、攔截*.do、*.htm, 例如:/user/add.do,這是最傳統(tǒng)的方式,最簡(jiǎn)單也最實(shí)用。不會(huì)導(dǎo)致靜態(tài)文件(jpg,js,css)被攔截。--> 
    <!--2、攔截/,例如:/user/add,可以實(shí)現(xiàn)現(xiàn)在很流行的REST風(fēng)格。很多互聯(lián)網(wǎng)類型的應(yīng)用很喜歡這種風(fēng)格的URL。弊端:會(huì)導(dǎo)致靜態(tài)文件(jpg,js,css)被攔截后不能正常顯示。 --> 
    <url-pattern>/</url-pattern> <!--會(huì)攔截URL中帶“/”的請(qǐng)求。--> 
  </servlet-mapping> 

  <welcome-file-list><!--指定歡迎頁(yè)面--> 
    <welcome-file>login.html</welcome-file> 
  </welcome-file-list> 
  <error-page> <!--當(dāng)系統(tǒng)出現(xiàn)404錯(cuò)誤,跳轉(zhuǎn)到頁(yè)面nopage.html--> 
    <error-code>404</error-code> 
    <location>/nopage.html</location> 
  </error-page> 
  <error-page> <!--當(dāng)系統(tǒng)出現(xiàn)java.lang.NullPointerException,跳轉(zhuǎn)到頁(yè)面error.html--> 
    <exception-type>java.lang.NullPointerException</exception-type> 
    <location>/error.html</location> 
  </error-page> 
  <session-config><!--會(huì)話超時(shí)配置,單位分鐘--> 
    <session-timeout>360</session-timeout> 
  </session-config> 
</web-app>

四、spring加載

通過(guò)上面的了解,我們可以看出spring核心配置文件就是listener那塊。在監(jiān)聽(tīng)之前我們已經(jīng)通過(guò)context-param將spring配置文件傳到上下文中了(application)。下面我們就來(lái)看看spring是如何工作的吧

第一步:

點(diǎn)開(kāi)listener源碼,我們發(fā)現(xiàn)他有下面幾個(gè)方法。和繼承的關(guān)系。我們發(fā)現(xiàn)他實(shí)現(xiàn)了ContextLoaderListener這個(gè)接口,這個(gè)接口在參數(shù)設(shè)置好之后自動(dòng)執(zhí)行contextInitialized方法的。

Spring MVC的web.xml配置詳解

那么我們來(lái)看看contextInitialized方法

Spring MVC的web.xml配置詳解

public WebApplicationContext initWebApplicationContext(ServletContext servletContext) {
    if (servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null) {
      throw new IllegalStateException(
          "Cannot initialize context because there is already a root application context present - " +
          "check whether you have multiple ContextLoader* definitions in your web.xml!");
    }

    Log logger = LogFactory.getLog(ContextLoader.class);
    servletContext.log("Initializing Spring root WebApplicationContext");
    if (logger.isInfoEnabled()) {
      logger.info("Root WebApplicationContext: initialization started");
    }
    long startTime = System.currentTimeMillis();

    try {
      // Store context in local instance variable, to guarantee that
      // it is available on ServletContext shutdown.
      if (this.context == null) {
        this.context = createWebApplicationContext(servletContext);
      }
      if (this.context instanceof ConfigurableWebApplicationContext) {
        ConfigurableWebApplicationContext cwac = (ConfigurableWebApplicationContext) this.context;
        if (!cwac.isActive()) {
          // The context has not yet been refreshed -> provide services such as
          // setting the parent context, setting the application context id, etc
          if (cwac.getParent() == null) {
            // The context instance was injected without an explicit parent ->
            // determine parent for root web application context, if any.
            ApplicationContext parent = loadParentContext(servletContext);
            cwac.setParent(parent);
          }
          configureAndRefreshWebApplicationContext(cwac, servletContext);
        }
      }
      servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context);

      ClassLoader ccl = Thread.currentThread().getContextClassLoader();
      if (ccl == ContextLoader.class.getClassLoader()) {
        currentContext = this.context;
      }
      else if (ccl != null) {
        currentContextPerThread.put(ccl, this.context);
      }

      if (logger.isDebugEnabled()) {
        logger.debug("Published root WebApplicationContext as ServletContext attribute with name [" +
            WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]");
      }
      if (logger.isInfoEnabled()) {
        long elapsedTime = System.currentTimeMillis() - startTime;
        logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms");
      }

      return this.context;
    }
    catch (RuntimeException ex) {
      logger.error("Context initialization failed", ex);
      servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
      throw ex;
    }
    catch (Error err) {
      logger.error("Context initialization failed", err);
      servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err);
      throw err;
    }
  }

仔細(xì)研究官方解釋,就是在這里初始化application,這里會(huì)用到contextClass+contextConfigLocation兩個(gè)參數(shù),如果contextClass在context-param提供了,我們就會(huì)根據(jù)這一個(gè)class去初始化application,很顯然我們正常配置都沒(méi)有配這個(gè),而是配置了后者,配置了后者就會(huì)去根據(jù)contextConfigLocation中提供的配置文件去解析然后創(chuàng)建相關(guān)的bean和application操作,這個(gè)方法的最后會(huì)執(zhí)行configureAndRefreshWebApplicationContext方法。這個(gè)方法就是在根據(jù)contextConfigLocation提供的配置文件中創(chuàng)建相關(guān)的bean。

五、springMVC 加載

springMVC其實(shí)和spring是一樣的,但是他不用再程序開(kāi)始時(shí)訪問(wèn)

  <servlet> 
    <!-- 配置DispatcherServlet --> 
    <servlet-name>springMvc</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
      <!-- 指定spring mvc配置文件位置 不指定使用默認(rèn)情況 --> 
      <init-param>   
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring/spring-mvc.xml</param-value>
      </init-param> 
    <!-- 設(shè)置啟動(dòng)順序 --> 
    <load-on-startup>1</load-on-startup> 
  </servlet>

  <!-- ServLet 匹配映射 -->
  <servlet-mapping>
    <servlet-name>springMvc</servlet-name>
    <url-pattern>*.zxh</url-pattern>
  </servlet-mapping>

看DispatcherServlet源碼中對(duì)contextConfigLocation參數(shù)的解釋

Spring MVC的web.xml配置詳解

上面明確指出我們這個(gè)參數(shù)給XmlWebApplicationContext類的,我們?cè)谶M(jìn)入XmlWebApplicationContext類看看究竟。

Spring MVC的web.xml配置詳解

這樣我們很容易理解為什么springmvc默認(rèn)的配置文件會(huì)在WEB-INF/application.xml中的吧。

在dispatcherservlet中有一個(gè)初始化方法,這里就初始化配置中一些東西,比如說(shuō)文件上傳適配器的配置等等。

protected void initStrategies(ApplicationContext context) {
    initMultipartResolver(context);
    initLocaleResolver(context);
    initThemeResolver(context);
    initHandlerMappings(context);
    initHandlerAdapters(context);
    initHandlerExceptionResolvers(context);
    initRequestToViewNameTranslator(context);
    initViewResolvers(context);
    initFlashMapManager(context);
  }

總結(jié)

spring+springmvc在配置中主要就是上面的兩個(gè)配置,當(dāng)然spring的強(qiáng)大不是我們一兩天能夠研究來(lái)的,我上面只是簡(jiǎn)單的研究討論了一下。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

分享名稱:SpringMVC的web.xml配置詳解
文章路徑:http://bm7419.com/article46/jjcdeg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、網(wǎng)站設(shè)計(jì)公司、手機(jī)網(wǎng)站建設(shè)、定制開(kāi)發(fā)網(wǎng)站建設(shè)、搜索引擎優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化