• SpringMVC 非注解配置


    web.xml配置:

    <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/springmvc/*.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    /WEB-INF/springmvc/路径下文件结构:

    controller配置

    servlet-controller.xml

    1 <bean name="testController" class="com.controller.TestController">
    2     <property name="testService" ref="testService"></property>
    3     <property name="methodNameResolver" ref="parameterResolver"></property>
    4 </bean>

    servlet-forward.xml

    URL handler处理配置
    servlet-handler.xml

    1 <bean id="firstHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    2     <property name="order" value="1"></property>
    3     <property name="alwaysUseFullPath" value="true"></property>
    4     <property name="mappings">
    5         <props>
    6             <prop key="test.do">testController</prop>
    7         </props>
    8     </property>
    9 </bean>

    拦截器配置
    servlet-interceptor.xml

    视图配置
    servlet-resolver.xml

    1 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    2     <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
    3 </bean>
    4 
    5 <bean id="parameterResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
    6     <property name="paramName" value="method"></property>
    7 </bean>
  • 相关阅读:
    同步/异步/阻塞/非阻塞
    java io异步
    java nio知识点总结
    使用BBED恢复数据文件头
    Codeforces Round #257 (Div. 2) B Jzzhu and Sequences
    Hibernate @Embeddable注解
    2388 Who&#39;s in the Middle(简单排序)
    CorePlot学习
    九度OJ 1179 阶乘(模拟)
    NSHashTable 和 NSMapTable学习
  • 原文地址:https://www.cnblogs.com/mingluosunshan/p/5445988.html
Copyright © 2020-2023  润新知