配置web.xml

    <!--配置spring-MVC拦截-->
<servlet>
<servlet-name>DispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>DispatcherServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

spring配置文件:DispatcherServlet-servlet.xml

<?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"
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/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-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"> <!-- 1. 配置处理器映射,springmvc默认的处理器映射器
BeanNameUrlHandlerMapping:根据bean的name属性的url去找handlerController -->
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean> <!--根据浏览器url匹配简单url的key,key就是Controller的id找到Controller-->
<!--注:不常用-->
<!-- <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/user1.do">userController</prop>
<prop key="/user2.do">userController</prop>
<prop key="/user3.do">userController</prop>
</props>
</property>
</bean>-->
<!--根据类名(MyController)类名.do来访问,类名首字母小写,测试得出如果类名中间出现大写会将后面截取掉-->
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean> <!-- 2. 配置处理器适配置器执行Controller -->
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"></bean> <!--可以与上面的处理适配器共存,区别是实现HttpRequestHandler接口,接口没有返回值-->
<bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"></bean> <!-- 3.配置一个控制器 -->
<bean name="/userController.do" class="com.royal.backoffice.web.controller.UserController"></bean> <!-- 4.配置springmvc视图解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean> </beans>

spring-mvc基于xml的配置的更多相关文章

  1. Spring学习--基于 XML 的配置声明切面

    正常情况下 , 基于注解的生命要优先于基于 XML 的声明. 通过 AspectJ 注解 , 切面可以与 AspectJ 兼容 , 而基于 XML 的配置则是 Spring 专有的.由于 Aspect ...

  2. Spring MVC 的xml一些配置

    1.可以自动加载注解驱动,通过注解找到对应Controller <!-- spring MVC 注解驱动 --> <mvc:annotation-driven></mvc ...

  3. idea的spring整合基于xml文件配置的mybatis报Invalid bound statement (not found): com.music.dao.MusicDao.findAll的问题

    一. 题主当时就是自己尝试整合spring和mybatis的时候遇到了这个问题,当时题主只看到了用注解的方式配置的dao层,题主用的是xml文件配置的形式, 而且坑爹的是题主的两个文件的路径写的也不一 ...

  4. Spring IoC — 基于XML的配置

    1.属性注入 注意点: 1)如果类中显示定义了一个带参的构造函数,则一定还要显示提供一个无参构造函数,否则使用属性注入时将抛出异常. 2)JavaBean关于属性命名的特殊规范.Spring只会检查B ...

  5. (spring-第2回【IoC基础篇】)Spring的Schema,基于XML的配置

    要深入了解Spring机制,首先需要知道Spring是怎样在IoC容器中装配Bean的.而了解这一点的前提是,要搞清楚Spring基于Schema的Xml配置方案. 在深入了解之前,必须要先明白几个标 ...

  6. Spring框架入门之基于xml文件配置bean详解

    关于Spring中基于xml文件配置bean的详细总结(spring 4.1.0) 一.Spring中的依赖注入方式介绍 依赖注入有三种方式 属性注入 构造方法注入 工厂方法注入(很少使用,不推荐,本 ...

  7. Spring MVC 的 XML 配置方式

    索引: 开源Spring解决方案--lm.solution 参看代码 GitHub: solution/pom.xml solution/webapi/pom.xml solution/mapper/ ...

  8. spring mvc 基于注解 配置默认 handlermapping

    spring mvc 是类似于 Struts 的框架.他们都有一个最主要的功能就是URL路由.URL路由能将请求与响应请求处理逻辑的类(在Struts中即是action,在spring mvc 中即是 ...

  9. Spring MVC Web.xml配置

    Web.xml spring&spring mvc 在web.xml中定义contextConfigLocation参数,Spring会使用这个参数去加载所有逗号分隔的xml文件,如果没有这个 ...

  10. Spring 框架的概述以及Spring中基于XML的IOC配置

    Spring 框架的概述以及Spring中基于XML的IOC配置 一.简介 Spring的两大核心:IOC(DI)与AOP,IOC是反转控制,DI依赖注入 特点:轻量级.依赖注入.面向切面编程.容器. ...

随机推荐

  1. win10编译libpng

    libpng在windows的编译. ligpng的官网介绍如下: libpng is the official PNG reference library. It supports almost a ...

  2. 记Windows下初次使用dev C++进行socket编程过程

    记初次接触socket编程,在devC++使用Winsock进行socket编程的一个过程,通过在devC++创建2个项目分别是server.client程序项目,感受通过socket使client与 ...

  3. SQL语句、PL/SQL块和SQL*Plus命令之间的区别

    SQL语句.PL/SQL块和SQL*Plus命令之间的区别   原文链接:https://blog.csdn.net/liuzhushiqiang/article/details/12320941 在 ...

  4. 吴裕雄--天生自然MySQL学习笔记:MySQL LIKE 子句

    在 MySQL 中使用 SQL SELECT 命令来读取数据, 同时我们可以在 SELECT 语句中使用 WHERE 子句来获取指定的记录. WHERE 子句中可以使用等号 = 来设定获取数据的条件, ...

  5. Ctrl +c 脚本中

    #!/bin/bashsar -n DEV 1 111111111111111 >>1.txt &   #实时网卡流量数据  sleep 3 && kill -2 ...

  6. //使用PDO连接mysql数据库

    <?php //使用PDO连接mysql数据库 class pdo_con{     var $dsn = 'mysql:dbname=test; host:127.0.0.1';     va ...

  7. UVA 10801 多线程最短路

    题意:一栋摩天大楼从0层到K层,有N部电梯,每个电梯都有自己的运行速度,此外,对于某个电梯来说,并不是每一层都会停,允许在某一层进行电梯换乘,每次换乘固定消耗60秒,最终求从0层去K层的最短时间,如果 ...

  8. MVC的异步模式

    [小家Spring]高性能关键技术之---体验Spring MVC的异步模式(Callable.WebAsyncTask.DeferredResult) 基础使用篇 https://blog.csdn ...

  9. python装饰器的参数传递

    被装饰器装饰的函数名即使没有被调用(因为有@xxx,会触发运行装饰器),(装饰器工厂函数)定义装饰器的代码已经运行了(最内部的那个函数并没有运行)(把被装饰的原函数引用赋值给了装饰器内部的那个函数名) ...

  10. 886A. ACM ICPC#均值分配问题(暴力)

    题目出处:http://codeforces.com/problemset/problem/886/A 题目大意:已知六个人得分,问是否能分成两个三人队使得每个队伍得分加和相等 #include< ...