1.创建后台配置文件springmvc-back.xml
<context:component-scan base-package="cn.liu" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> <!-- jsp视图 --> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/back_page/" /> <property name="suffix" value=".jsp" /> </bean>
2.创建前台配置文件springmvc-front.xml
<context:component-scan base-package="cn.liu" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> <!-- jsp视图 --> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/back_page/" /> <property name="suffix" value=".jsp" /> </bean>
3.配置web.xml
<!-- springmvc 后台配置 --> <servlet> <servlet-name>back</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc-back.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>back</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- springmvc 前台配置 --> <servlet> <servlet-name>front</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc-front.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>front</servlet-name> <url-pattern>*.shtml</url-pattern> </servlet-mapping>
本文出自 “老牛Java” 博客,请务必保留此出处http://liuyj.blog.51cto.com/2340749/1712021
06(maven+SSH)网上商城项目实战之springmvc配置
原文地址:http://liuyj.blog.51cto.com/2340749/1712021