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>
  • 相关阅读:
    20.GC日志详解及日志分析工具
    19.JVM调优工具锦囊
    两个页面的传参(转自博客园的春哥也编程)
    纯js实现背景图片切换
    关于引用类型用ref传参的问题
    C++ return
    C++内存管理
    Chrome插件开发一(配置文件)
    C++对象传递
    const 与 #define 的比较
  • 原文地址:https://www.cnblogs.com/stono/p/4480880.html
Copyright © 2011-2022 走看看