标签:intern als oca class 自动注册 att scan ada param
1.pom.xml中down相应依赖(SpringMVC需要的jar包)
2.在web.xml中添加关于springmvc-servlet.xml的配置
<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:springmvc-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
3.配置springmvc-servlet.xml
<!--自动注册DefaultAnnotationHandlerMapping与AnnotationMethodHandlerAdapter 两个bean,是@Controller注解使用的前提配置 -->
<mvc:annotation-driven />
<!--使静态资源可以正常访问 -->
<mvc:default-servlet-handler />
<!--springMvc 扫包 @Controller -->
<!--use-default-filters="false" 加上include-filter type="annotation" expression="org.springframework.stereotype.Controller"让其只扫描com.duu.controller包-->
<context:component-scan base-package="com.duu" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!--配置跳转jsp前缀,后缀 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
标签:intern als oca class 自动注册 att scan ada param
原文地址:http://www.cnblogs.com/fanshu/p/7810172.html