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

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>
阅读更多
想对作者说点什么? 我来说一句

springMVC+mybatis的示例项目

2014年09月21日 6.36MB 下载

没有更多推荐了,返回首页

不良信息举报

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

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭