• springmvc两种非注解的处理器映射器


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.2.xsd   
            http://www.springframework.org/schema/aop 
            http://www.springframework.org/schema/aop/spring-aop-3.2.xsd   
            http://www.springframework.org/schema/tx 
            http://www.springframework.org/schema/tx/spring-tx-3.2.xsd   
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-3.2.xsd">
        
        <!-- 配置处理器映射器 -->
        <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean>
        
        <!-- 配置处理器适配器 -->
        <!-- 以bean的name属性值作为url -->
        <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"></bean>
        
        <!-- 以bean的id属性值作为url -->
        <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <prop key="/user1.action">user</prop>
                    <prop key="/user2.action">user</prop>
                </props>
            </property>
        </bean>
        <!-- 配置视图解析器 -->
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"></bean>
        
        <!-- controller -->
        <bean id="user" name="/user.action" class="com.zhou.controller.UserController"></bean>
    </beans>

    两种处理器映射器都可以共存不相互影响。

  • 相关阅读:
    mysql、mongodb、redis区别
    Redis面试题
    【开发提效】开发提效技巧
    【代码规范】16条军规
    mysql数据库连接字符串
    mysql数据库连接字符串
    好用的api接口
    node + express + vue
    跨源资源共享(CORS)
    fehelper
  • 原文地址:https://www.cnblogs.com/zhouquan-1992-04-06/p/6528656.html
Copyright © 2020-2023  润新知