<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> <!-- 配置SpringMVC --> <!-- 1.开启SpringMVC注解模式 -->
<!-- 简化配置:
(1)自动注册DefaultAnootationHandlerMapping,AnotationMethodHandlerAdapter
(2)提供:数据绑定,数字和日期的format(@NumberFormat, @DateTimeFormat), xml,json默认读写支持 -->
<mvc:annotation-driven/> <!-- 2.静态资源默认servlet配置(以下二选一)
(1)加入对静态资源的处理:js,gif,png
(2)允许使用"/"做整体映射 -->
<!--允许静态资源放在任何地方,如WEB-INF目录下、类路径下等-->
<mvc:resources location="/resources/" mapping="/resources/**"/> 在SpringMVC3.0之后推荐使用一:
<mvc:annotation-driven />
<mvc:resources location="/img/" mapping="/img/**"/>
<mvc:resources location="/js/" mapping="/js/**"/>
<mvc:resources location="/css/" mapping="/css/**"/>
说明:
location元素表示webapp目录下的static包下的所有文件;
mapping元素表示以/static开头的所有请求路径,如/static/a 或者/static/a/b; <!--配置<mvc:default-servlet-handler/>后,
会在Spring MVC上下文中定义一个org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler,
它会像一个检查员,对进入DispatcherServlet的URL进行筛查,
如果发现是静态资源的请求,就将该请求转由Web应用服务器默认的Servlet处理,
如果不是静态资源的请求,才由DispatcherServlet继续处理。-->
<mvc:default-servlet-handler/> <!-- 3.定义视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/html/"></property>
<property name="suffix" value=".html"></property>
</bean> <!-- 在spring-mvc.xml文件中加入这段配置后,spring返回给页面的都是utf-8编码了 -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean> <!-- 4.扫描controller相关的bean -->
<!-- ** 匹配任意class文件和包,而 * 只能匹配包,因此无法扫描到包下的类 -->
<!-- controller.** (等同于controller)和 controller.*contrller( 以dao结尾的包通配) -->
<context:component-scan base-package="controller"/> <!-- 5.权限拦截器 -->
<mvc:interceptors> <mvc:interceptor>
<mvc:mapping path="/login/**"/>
<mvc:exclude-mapping path="/login/top"/>
<bean id="loginInterceptor"
class="com.LoginInterceptor"/>
</mvc:interceptor> </mvc:interceptors> </beans>

配置文件一spring-mvc.xml的更多相关文章

  1. spring mvc: xml生成

    spring mvc: xml生成 准备: javax.xml.bind.annotation.XmlElement; javax.xml.bind.annotation.XmlRootElement ...

  2. Spring MVC Xml视图解析器

    XmlViewResolver用于在xml文件中定义的视图bean来解析视图名称.以下示例演示如何在Spring Web MVC框架使用XmlViewResolver. XmlViewResolver ...

  3. spring boot配置文件中 spring.mvc.static-path-pattern 配置项

    spring boot项目中的静态资源文件存放在static文件下面,当通过浏览器访问这些静态文件时,发现必须要添加static作为前缀才能访问,折腾了一番后发现,这个前缀跟 spring.mvc.s ...

  4. spring配置文件和spring mvc配置文件的区别

    Question: Are applicationContext.xml and spring-servlet.xml related anyhow in Spring Framework? Will ...

  5. Spring,SpringMvc配置常见的坑,注解的使用注意事项,applicationContext.xml和spring.mvc.xml配置注意事项,spring中的事务失效,事务不回滚原因

    1.Spring中的applicationContext.xml配置错误导致的异常 异常信息: org.apache.ibatis.binding.BindingException: Invalid ...

  6. spring mvc: xml练习

    xml练习,得到的结果是: <?xml version="1.0" encoding="UTF-8" standalone="yes" ...

  7. spring Mvc 执行原理 及 xml注解配置说明 (六)

    Spring MVC 执行原理 在 Spring Mvc 访问过程里,每个请求都首先经过 许多的过滤器,经 DispatcherServlet 处理; 一个Spring MVC工程里,可以配置多个的 ...

  8. Spring MVC视图解析器

    Spring MVC提供的视图解析器使用ViewResolver进行视图解析,实现浏览器中渲染模型.ViewResolver能够解析JSP.Velocity模板.FreeMarker模板和XSLT等多 ...

  9. Spring MVC 学习总结(四)——视图与综合示例

    一.表单标签库 1.1.简介 从Spring2.0起就提供了一组全面的自动数据绑定标签来处理表单元素.生成的标签兼容HTML 4.01与XHTML 1.0.表单标签库中包含了可以用在JSP页面中渲染H ...

  10. Mybatis 与 spring mvc

    本文是用来小结一下自己mybatis 和spring mvc 学习过程. 在写的过程中发现 http://www.phperz.com/article/15/0127/48684.html 这篇文章里 ...

随机推荐

  1. [USACO06JAN]牛的舞会The Cow Prom

    题目描述 The N (2 <= N <= 10,000) cows are so excited: it's prom night! They are dressed in their ...

  2. SSD 坏了

    系统盘是SSD,系统盘坏了. 桌面所有数据都拿不回来了. 真的无奈啊,来吧,统计一下,有多少东西要重装. VS2008.VS2010.VS2013.VS2015. GITHUB.SVN.VMWare. ...

  3. Django-ORM初识

    Django之ORM基础 一.ORM简介: ORM概念: 对象关系映射(Object Relational Mapping,简称ORM)模式是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术 ...

  4. javascript基础入门之js中的数据类型与数据转换01

    javascript基础入门之js中的数据结构与数据转换01 js的组成(ECMAScript.BOM.DOM)        js中的打印语句:        数据类型        变量      ...

  5. 异步action和redux-thunk理解

    异步action一般指的就是异步action创建函数 action创建函数分为同步action创建函数和异步action创建函数 同步action创建函数(最常见的): function reques ...

  6. 笔记-Linux包管理命令

    一.apt, apt-get, dpkg命令 apt-get是一条linux命令,适用于deb包管理式的操作系统,主要用于自动从互联网的软件仓库中搜索.安装.升级.卸载软件或操作系统.使用apt-ge ...

  7. sqlmap结合burpsuite对post请求进行注入测试

    1. 浏览器打开目标地址 http://testasp.vulnweb.com/Login.asp 2. 配置burp代理(127.0.0.1:8080)以拦截请求 3. 点击login表单的subm ...

  8. 自定义Java annotation

    1.目录结构: 2.pom文件: Simple exmple: package com.yuan.simple; import java.lang.annotation.Retention; impo ...

  9. ps切图的基本操作

    参考线和辅助线 ctrl+r呼出标尺,只有在移动工具(快捷键v)下,鼠标左键从标尺上可以拖出来新的参考线.将参考线拖回标尺即是删除. 导出切片 快捷键ctrl+alt+shift+s ,选择png-2 ...

  10. C# 与 C/C++ 网络传输字符串解决方案

    { 不管你的数据加没加密,只要有中文,请转16进制后再处理,把16进制再转为GB2312的byte再发送, 接收的话同样 c++ 发送时转16进制再发送,c#16进制转字符串后再转GB2312就可以了 ...