spring mvc配置文件dispatcher-servlet.xml详解

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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-3.2.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
     <!-自动扫描controller--->
    <context:component-scan base-package="com.zenointel.p2p.web.controller"/>
    <!--验证器-->
    <mvc:annotation-driven validator="validtor">
        <mvc:message-converters>
            <bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
        </mvc:message-converters>
    </mvc:annotation-driven>

    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
        <property name="cookieMaxAge" value="31536000" />
    </bean>

    <mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/**"/>
            <mvc:exclude-mapping path="/services/**"/>
            <mvc:exclude-mapping path="/css/**"/>
            <mvc:exclude-mapping path="/js/**"/>
            <mvc:exclude-mapping path="/img/**"/>
            <mvc:exclude-mapping path="/fonts/**"/>
            <mvc:exclude-mapping path="/webfile/**"/>
            <mvc:exclude-mapping path="/theme/**"/>
            <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
        </mvc:interceptor>
        <mvc:interceptor>
            <mvc:mapping path="/**"/>
            <mvc:exclude-mapping path="/services/**"/>
            <mvc:exclude-mapping path="/css/**"/>
            <mvc:exclude-mapping path="/js/**"/>
            <mvc:exclude-mapping path="/img/**"/>
            <mvc:exclude-mapping path="/fonts/**"/>
            <mvc:exclude-mapping path="/webfile/**"/>
            <mvc:exclude-mapping path="/theme/**"/>
            <bean class="com.zenointel.p2p.web.interceptor.P2PInterceptor"/>
        </mvc:interceptor>
    </mvc:interceptors>

    <mvc:resources mapping="/favicon.ico" location="/"/>
    <mvc:resources mapping="/css/**" location="/css/"/>
    <mvc:resources mapping="/js/**" location="/js/"/>
    <mvc:resources mapping="/img/**" location="/img/"/>
    <mvc:resources mapping="/fonts/**" location="/fonts/"/>
    <mvc:resources mapping="/theme/**" location="/theme/"/>

    <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

    <bean id="captchaProducer"
          class="com.google.code.kaptcha.impl.DefaultKaptcha">
        <property name="config">
            <bean class="com.google.code.kaptcha.util.Config">
                <constructor-arg type="java.util.Properties">
                    <props>
                        <prop key="kaptcha.image.width">100</prop>
                        <prop key="kaptcha.image.height">30</prop>
                        <prop key="kaptcha.textproducer.char.string">0123456789</prop>
                        <prop key="kaptcha.textproducer.char.length">4</prop>
                        <prop key="kaptcha.textproducer.font.size">30</prop>
                        <prop key="kaptcha.textproducer.font.color">black</prop>

                    </props>
                </constructor-arg>
            </bean>
        </property>
    </bean>
 <!--================ 中文国际化================-->
    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="classpath:messageSource"/>
        <property name="cacheSeconds" value="300"/>
    </bean>

    <bean id="validtor" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
        <property name="validationMessageSource" ref="messageSource"/>
    </bean>
 <!--================ 文件上传================-->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="20971520"/>
        <property name="resolveLazily" value="true"/>
    </bean>

    <context:property-placeholder order="1" location="classpath:application.xml" />

    <bean id="webConfig" class="com.zenointel.p2p.web.util.WebConfig" />

</beans>
时间: 2024-08-07 08:17:01

spring mvc配置文件dispatcher-servlet.xml详解的相关文章

Spring MVC 文件上传功能详解

前言 在Spring MVC中实现文件上传功能并不复杂,前端使用HTML语法,后端使用特定抽象.参考Spring Boot相关文档即可.本文主要讲解常见资料忽略的两个问题: 文件上传错误 链接重置问题 版本:Spring Boot 1.5x 文件上传错误 一个关注点是如何处理文件上传期间发生的错误,错误主要分为两类: IOException 文件读取或写入错误. MultipartException 上传文件时,超过文件大小上限所触发的异常. IOException 只需要在Controller

spring boot 配置文件properties和YAML详解

properties中配置信息并获取值. 1:在application.properties配置文件中添加: 根据提示创建直接创建. 怎么在程序中引用这个值呢? 浏览器访问: 我们可以看到输出的值. 说明: Application属性配置文件的优先顺序 2:端口修改 在application.properties中直接使用: server.port=8888 保存后,spring boot会自动帮我们重启. 我们可以看到重启后的端口就为8888了. 3:日期格式: 在上一节课中我们访问saveu

spring配置文件[servlet-name]-servlet.xml

注解式控制器简介: 在spring2.5之前都是通过实现controller接口或其实现来定义处理器类. spring2.5开始支持通过注解@controller和@requestmapping来定义处理器类,DefaultAnnotationHandlerMapping.AnnotationMethodHandlerAdapter为@controller和@requestmapping提供支持. spring3.0引入restful架构风格支持,引入了更多的注解. spring3.1使用新的H

logback的使用和logback.xml详解,在Spring项目中使用log打印日志

logback的使用和logback.xml详解 一.logback的介绍 Logback是由log4j创始人设计的另一个开源日志组件,官方网站: http://logback.qos.ch.它当前分为下面下个模块: logback-core:其它两个模块的基础模块 logback-classic:它是log4j的一个改良版本,同时它完整实现了slf4j API使你可以很方便地更换成其它日志系统如log4j或JDK14 Logging logback-access:访问模块与Servlet容器集

(2) tomcat配置文件server.xml详解

1. 入门示例:虚拟主机提供web服务 该示例通过设置虚拟主机来提供web服务,因为是入门示例,所以设置极其简单,只需修改$CATALINA_HOME/conf/server.xml文件为如下内容即可,本文的tomcat安装在/application/tomcat下,因此$CATALINA_HOME=/application/tomcat. 其中大部分都采用了默认设置,只是在engine容器中添加了两个Host容器. <?xml version="1.0" encoding=&q

Tomcat主配置文件Server.xml详解

Tomcat主配置文件Server.xml详解 1.软件版本 [[email protected] META-INF]# java -version java version "1.8.0_60" Java(TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode) 2.server.xml组件类别 顶级组件:位于整个配置的

JavaEE学习之Maven配置文件pom.xml详解(转)

一.引言 (本文转载自:http://blog.csdn.net/longeremmy/article/details/9670619) 使用maven有一些时间了,一直没有好好将pom配置文件每个节点的意义好好了解一番.今天突然想来了解下:pom- project object model 项目对象模型.顾名思义,他是用来描述项目信息的,以及构建方式,依赖等.网上有一篇文章写的很详细,这里就借用一下,以备日后使用. 二.详解 1 <project xmlns="http://maven.

maven全局配置文件settings.xml详解

maven全局配置文件settings.xml详解 https://www.cnblogs.com/jingmoxukong/p/6050172.html?utm_source=gold_browser_extension 各种标签说明,没有<distributionManagement> 原文地址:https://www.cnblogs.com/stono/p/9456886.html

Web.xml详解(转)

这篇文章主要是综合网上关于web.xml的一些介绍,希望对大家有所帮助,也欢迎大家一起讨论. ---题记 一.            Web.xml详解: (一)  web.xml加载过程(步骤) 首先简单说一下,web.xml的加载过程. 当我们去启动一个WEB项目时,容器包括(JBoss.Tomcat等)首先会读取项目web.xml配置文件里的配置,当这一步骤没有出错并且完成之后,项目才能正常地被启动起来. l  启动WEB项目的时候,容器首先会去它的配置文件web.xml读取两个节点: 

(转)struts2.0配置文件、常量配置详解

一.配置: 在struts2中配置常量的方式有三种: 在struts.xml文件中配置 在web.xml文件中配置 在sturts.propreties文件中配置 1.之所以使用struts.propreties文件配置,是因为为了保持与WebWork的向后兼容 2.在实际开发中,在web.xml中配置常量相比其他两种,需要更多的代码量,会降低了web.xml的可读性 3.通常推荐在struts.xml文件中配置struts2的常量,而且便于集中管理 sturt2中搜索加载常量的顺序是: str