手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

SpringMVC,Spring,MyBatis集成配置SpringMVC

时间:2024-10-12 21:30:05

1、配置组件扫描路径:<context:component-scan base-package="com.gwolf"> </context:component-scan>

SpringMVC,Spring,MyBatis集成配置SpringMVC

2、如果你的eclipse开发工具不能通过工具自动添加spring相关的namespace,请安装spring相关插件,下图相关的东西是安装插件才会出现的。

SpringMVC,Spring,MyBatis集成配置SpringMVC

3、SpringMVC不能扫描所有的组件,只让它扫描控制器的组件<context:component-scan base-package="com.gwolf"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan>

SpringMVC,Spring,MyBatis集成配置SpringMVC

4、禁用黏聪鲆熊掉组件扫描默认规则<context:component-scan base-package="com.gwolf" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan>

SpringMVC,Spring,MyBatis集成配置SpringMVC

5、配置视图解析器,方便页面返回<bean class="org.springframework.web.servlet.即枢潋雳view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"></property> <property name="suffix" value=".jsp"></property> </bean>

SpringMVC,Spring,MyBatis集成配置SpringMVC

6、将springmvc不能处理的请求交给tomcat处理<mvc:default-servlet-handler/>

SpringMVC,Spring,MyBatis集成配置SpringMVC

7、配置能支持springmvc更高级的一些功能,JSR303校验,快捷的ajax请求,映射动态请求<mvc:annotation-driven />

SpringMVC,Spring,MyBatis集成配置SpringMVC
© 手抄报圈