1、配置组件扫描路径:<context:component-scan base-package="com.gwolf"> </context:component-scan>
2、如果你的eclipse开发工具不能通过工具自动添加spring相关的namespace,请安装spring相关插件,下图相关的东西是安装插件才会出现的。
3、SpringMVC不能扫描所有的组件,只让它扫描控制器的组件<context:component-scan base-package="com.gwolf"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan>
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>
5、配置视图解析器,方便页面返回<bean class="org.springframework.web.servlet.即枢潋雳view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"></property> <property name="suffix" value=".jsp"></property> </bean>
6、将springmvc不能处理的请求交给tomcat处理<mvc:default-servlet-handler/>
7、配置能支持springmvc更高级的一些功能,JSR303校验,快捷的ajax请求,映射动态请求<mvc:annotation-driven />