1 2 3 4 五 6 7 8 9 10 11 12 13 14 15 |
web.xml文件配置 <! - 配置springmvcDispatcherServlet的设置并配置映射 - > 的<servlet> <servlet的名称>用SpringMVC </ servlet的名称> <servlet的类> org.springframework.web.servlet.DispatcherServlet </ servlet的类> <INIT-PARAM> <PARAM名称> contextConfigLocation的</ PARAM名称> <PARAM值>类路径:用SpringMVC-servlet.xml中</ PARAM值> </ INIT-param> <! - <load-on-startup> 1 </ load-on-startup> - > </ servlet的>
<servlet的映射> <servlet的名称>用SpringMVC </ servlet的名称> <URL模式> / </ URL模式> </ servlet的映射>
用SpringMVC-servlet.xml中配置
<?xml version =“1.0”encoding =“UTF-8”?> <beans xmlns =“ http://www.springframework.org/schema/beans ” xmlns:xsi =“ http://www.w3.org/2001/XMLSchema-instance ” xmlns:context =“ http://www.springframework.org/schema/context ” xmlns:mvc =“ http://www.springframework.org/schema/mvc ” xsi:schemaLocation =“ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd “>
<! - 扫描程序组件 - > <context:component-scan base-package =“test.SpringMVC”/>
<! - 如果您使用注释,则必须配置以下设置 - > <mvc:annotation-driven />
<! - 配置InternalResourceViewResolver - > <bean class =“org.springframework.web.servlet.view.InternalResourceViewResolver” ID = “的InternalResourceViewResolver”> <! - 前缀 - > <property name =“prefix”value =“/ WEB-INF / jsp /”/> <! - 后缀 - > <property name =“suffix”value =“。jsp”/> </豆> </豆> |
SpringMVC配置详解
最新推荐文章于 2024-07-29 06:30:00 发布