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>
  • 相关阅读:
    HDU 1698 Just a Hook (线段树模板题-区间求和)
    spring定时任务详解(@Scheduled注解)
    spring定时任务(@Scheduled注解)
    java反射实现接口重试
    微信开发者工具在线调试
    消息队列应用场景
    Redis、Memcache和MongoDB的区别
    下拉框多选实现回显及sql
    MySQL 中 You can't specify target table '表名' for update in FROM clause错误解决办法
    catch异常
  • 原文地址:https://www.cnblogs.com/stono/p/4480880.html
Copyright © 2011-2022 走看看