You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.9 KiB
58 lines
2.9 KiB
<?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 https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd"> |
|
<!--自动扫描--> |
|
<!--扫描的包名和自己项目保持一致--> |
|
<context:component-scan base-package="cc.bnblogs"></context:component-scan> |
|
<!--配置视图解析器--> |
|
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> |
|
<property name="prefix" value="/"></property> |
|
<property name="suffix" value=".jsp"></property> |
|
</bean> |
|
<mvc:annotation-driven conversion-service="conversionService"> |
|
<!--消息转换器配置--> |
|
<!--用于解决controller返回给前端的数据乱码的问题--> |
|
<mvc:message-converters register-defaults="true"> |
|
<bean class="org.springframework.http.converter.StringHttpMessageConverter"> |
|
<property name="supportedMediaTypes" value="text/html;charset=UTF-8"/> |
|
</bean> |
|
<bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"> |
|
<property name="supportedMediaTypes"> |
|
<list> |
|
<value>application/json;charset=UTF-8</value> |
|
</list> |
|
</property> |
|
</bean> |
|
</mvc:message-converters> |
|
</mvc:annotation-driven> |
|
|
|
<!--配置自定义转换器--> |
|
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"> |
|
<property name="converters"> |
|
<list> |
|
<!--配置日期转换器--> |
|
<bean class="cc.bnblogs.converter.DateConverter"> |
|
<constructor-arg type="java.lang.String" value="yyyy-MM-dd"/> |
|
</bean> |
|
|
|
<!--配置学生数据转换器--> |
|
<bean class="cc.bnblogs.converter.StudentConverter"> |
|
</bean> |
|
</list> |
|
|
|
</property> |
|
</bean> |
|
<!--配置文件组件--> |
|
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> |
|
</bean> |
|
<!--注入自定义验证器--> |
|
<bean id="accountValidator" class="cc.bnblogs.validator.AccountValidator" /> |
|
<!--注册自定义验证器--> |
|
<mvc:annotation-driven validator="accountValidator"/> |
|
<!--使用JSR303校验必须加上这个配置--> |
|
<!--启用MVC--> |
|
<mvc:annotation-driven></mvc:annotation-driven> |
|
</beans> |