首页 > 编程语言 > 详细

springmvc配置

时间:2015-11-13 11:48:00      阅读:317      评论:0      收藏:0      [点我收藏+]

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://9840338.blog.51cto.com/9830338/1712368

springmvc配置

原文:http://9840338.blog.51cto.com/9830338/1712368

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!