关闭

06 网上商城项目实战之springmvc配置

219人阅读 评论(0) 收藏 举报

1.创建后台配置文件springmvc-back.xml

1
2
3
4
5
6
7
8
9
10
11
    <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    

1
2
3
4
5
6
7
8
9
10
11
    <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
  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 <!-- 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>
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:3942次
    • 积分:83
    • 等级:
    • 排名:千里之外
    • 原创:2篇
    • 转载:16篇
    • 译文:0篇
    • 评论:0条
    文章存档