美文网首页
spring-mvc

spring-mvc

作者: 别叫我小新 | 来源:发表于2018-09-06 23:20 被阅读0次
    <?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:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
        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/aop
            http://www.springframework.org/schema/aop/spring-aop.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc.xsd">
            
          <context:component-scan base-package="com.qianfeng" use-default-filters="false">
                <!-- 指定扫描的注解 -->
                <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
           </context:component-scan>
           
           <!-- 使用指定的验证器 -->
           <mvc:annotation-driven validator="validator" conversion-service="convertorService" ></mvc:annotation-driven>
           
           <!-- 配置资源文件 -->
        <bean id="hibernateMessages" class="org.springframework.context.support.ResourceBundleMessageSource">
            <property name="defaultEncoding" value="UTF-8"></property>
            <property name="basenames">
                <list>
                    <value>ValidationMessages</value>
                </list>
            </property>
       </bean>
            <!-- 配置验证器 -->
        <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
            <property name="providerClass" value="org.hibernate.validator.HibernateValidator"></property>
            <property name="validationMessageSource" ref="hibernateMessages"></property>
        </bean>
           
           <mvc:resources location="/js/" mapping="/js/**"></mvc:resources>
           <mvc:resources location="/" mapping="/**"></mvc:resources>
           
            <!-- 视图解析器   跳转到相关jsp的资源时,只写资源的名字就可以 -->
            <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                <!-- 前缀 -->
                <property name="prefix" value="/"></property>
                <!-- 后缀 -->
                <property name="suffix" value=".jsp"></property>
            </bean>
            
             <!-- 设置自定义的转换器 -->
         <bean id="convertorService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
            <property name="converters">
                <list>
                    <bean class="com.qianfeng.controller.CustomerIntConvert"></bean>
                </list>
            </property>
         </bean>
    </beans>

    相关文章

      网友评论

          本文标题:spring-mvc

          本文链接:https://www.haomeiwen.com/subject/ebaiwftx.html