1
在我web.xml
,主要配置如下:爲什麼rest-servlet,xml在SpringMVC中是必須的?
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-mvc-config.xml
</param-value>
</context-param>
<filter>
<filter-name>SetCharacterEncoding</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>
</filter>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
在我spring-mvc-config.xml
,只有2條線:
<mvc:annotation-driven />
<import resource="spring.xml" />
而接下來,在我spring.xml
,有春的所有東西配置,沒有任何關於springMVC配置。
當我開始這個web應用程序在Tomcat中,它總是拋出FileNotFoundException
上[WEB-INF /休息-servlet.xml中]後,我添加它,它只是正常工作。
我只想知道web.xml中的哪一部分指示rest-servlet.xml是WEB-INF目錄中的必備項。
我已經搜索了一下,但什麼都沒發現。任何人都可以幫我嗎?非常感謝!
+1您可以從相關問題中瞭解「原因和方式」:http://stackoverflow.com/q/7833767/839646 –