zoukankan      html  css  js  c++  java
  • spring mvc handler的三种方式

    springmvc.xml 三种方式不能针对一个controller同时使用

    <?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:mvc="http://www.springframework.org/schema/mvc"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/mvc
         http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-4.1.xsd">
        <!-- 1,配置handlerMapping 根据beanname找到对应的Controller -->
        <bean
            class="org.springframework.web.servlet.mvc.support.ControllerBeanNameHandlerMapping"></bean>
        <bean id="userController" name="/user.do"
            class="com.stone.controller.UserController"></bean>
        <!-- 2,根据简单URL来查找Controller -->
        <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <prop key="/userInfo.do">userController</prop>
                </props>
            </property>
        </bean>
        <bean id="userController" class="com.stone.controller.UserController"></bean>
        <!-- 3,控制类的类名访问Controller,访问时类名首字母需要小写 -->
        <bean
            class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"></bean>
        <bean class="com.stone.controller.UserController"></bean>
    
        <!-- 配置视图 解析器 -->
        <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <!-- 前缀和后缀 -->
            <property name="prefix" value="/"></property>
            <property name="suffix" value=".jsp"></property>
        </bean>
    </beans>
  • 相关阅读:
    第八章 对象
    第七章 压缩列表
    第六章 整数集合
    Java中的Unsafe
    站在Java的角度看LinkedList
    Java内部类详解
    浅析Java中的final关键字
    ConcurrentHashMap
    阻塞队列
    线程池的使用和实现
  • 原文地址:https://www.cnblogs.com/stono/p/4480880.html
Copyright © 2011-2022 走看看