首先說任何xml文件本質(zhì)上都是一個(gè)標(biāo)簽,標(biāo)簽內(nèi)部會(huì)嵌套子標(biāo)簽。
web.xml的根標(biāo)簽就是<web-app>。
文件內(nèi)標(biāo)簽的加載順序是:context-param -> listener -> filter -> servlet。
contextConfigLocationclasspath:spring/applicationContext*.xml
context-param定義全局參數(shù),這里是配置了Spring配置文件的位置。
org.springframework.web.context.ContextLoaderListener
監(jiān)聽器, 加載spring根環(huán)境 。
過濾器,常見功能有監(jiān)控,或者編解碼。
encodingFilterorg.springframework.web.filter.CharacterEncodingFilterencodingUTF-8forceEncodingtrueencodingFilter/*
加載springMVC環(huán)境(springmvc-servlet.xml),并監(jiān)聽/api/*路徑下的請(qǐng)求 。
springmvcorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:springmvc/springmvc-servlet.xmlspringmvc/api/*
入職新公司后,大塊寫文章的時(shí)間不多,只能抓緊早晚。這篇文章本打算上上周末寫的,竟拖到現(xiàn)在,其實(shí)也不麻煩。