springmvc-servlet.xml檔案配置,方法三
阿新 • • 發佈:2019-01-03
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <!-- springmvc的核心servlet 第一種:[servlet-name]-servlet.xml,比如:springmvc-servlet.xml,注意名字是固定的 第二種:改變名稱空間(推薦使用) 第一種和第二種都必須把配置檔案放置在web-inf目錄下。 第三種:通過contextConfigLocation 可以放置在任意地方 --> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <!--這裡使用了第三種方法,可以放在任意位置--> <param-name>contextConfigLocation</param-name> <param-value>classpath*:haomvc.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
可以放到任意位置