SpringMVC,Spring,MyBatis集成配置SpringMVC

2025-04-04 18:27:33

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
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢