06(maven+SSM)网上商城项目实战之springmvc配置

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>


你可能感兴趣的:(项目,配置文件,网上商城)