SpringMVC 数据校验自定义的错误消息文件和错误消息键值
2013-09-26 14:28
357 查看
<?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:batch="http://www.springframework.org/schema/batch"
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/batch http://www.springframework.org/schema/batch/spring-batch-2.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="springmvc" />
<!-- 默认注解映射的支持 -->
<mvc:annotation-driven validator="validator" />
<!-- <context:property-placeholder location="classpath:msg.properties" /> -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
<!-- <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"
/> -->
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="fileEncodings" value="utf-8" />
<property name="cacheSeconds" value="120" />
</bean>
<bean id="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="providerClass" value="org.hibernate.validator.HibernateValidator" />
<!-- 如果不加默认到使用classpath下的 ValidationMessages.properties -->
<property name="validationMessageSource" ref="messageSource" />
</bean>
<!-- <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters"> <list> <bean class="example.MyCustomConverter"
/> </list> </property> </bean> -->
</beans>
http://blog.csdn.net/songjinbin/article/details/14003533 统一异常处理
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:batch="http://www.springframework.org/schema/batch"
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/batch http://www.springframework.org/schema/batch/spring-batch-2.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="springmvc" />
<!-- 默认注解映射的支持 -->
<mvc:annotation-driven validator="validator" />
<!-- <context:property-placeholder location="classpath:msg.properties" /> -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
<!-- <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"
/> -->
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="fileEncodings" value="utf-8" />
<property name="cacheSeconds" value="120" />
</bean>
<bean id="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="providerClass" value="org.hibernate.validator.HibernateValidator" />
<!-- 如果不加默认到使用classpath下的 ValidationMessages.properties -->
<property name="validationMessageSource" ref="messageSource" />
</bean>
<!-- <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters"> <list> <bean class="example.MyCustomConverter"
/> </list> </property> </bean> -->
</beans>
http://blog.csdn.net/songjinbin/article/details/14003533 统一异常处理
相关文章推荐
- springMVC高级部分(数据校验,数据错误回显(自定义格式错误显示),拦截器,异常处理,文件上传,文件下载,springmvc运行流程以及springmvc和struts2对比)
- Android 与Springmvc之间交互若干问题(消息,文件,自定义dialog...)
- JavaEE开发之SpringMVC中的自定义消息转换器与文件上传
- JavaEE开发之SpringMVC中的自定义消息转换器与文件上传
- JavaEE开发之SpringMVC中的自定义消息转换器与文件上传
- JavaEE开发之SpringMVC中的自定义消息转换器与文件上传
- JavaEE开发之SpringMVC中的自定义消息转换器与文件上传
- 编译器错误消息: CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\ro
- 有关springmvc3.1.3文件上传,出现400 的错误问题
- 若要使他人能够在远程计算机上查看此特定错误消息的详细信息,请在位于当前 Web 应用程序根目录下的“web.config”配置文件中创建一个 <customErrors> 标记。然后应将此 <cust
- windows下IIS自定义404错误页面系统找不到指定的文件问题的解决方法
- 如何将sql 执行的错误消息 记录到本地文件中
- Java 简单解决springmvc获取properties文件里面中文内容出现论码问题(我遇到的问题是数据提交检验时返回的错误提示出现乱码)
- 应用springMVC时 JS等文件找不到错误
- C# 读取app.config配置文件 节点键值,提示 "配置系统未能初始化" 错误的解决方案
- springmvc配置的国际化资源文件显示为???key???的错误原因
- 关于SpringMVC下无法引用外部的js,css文件错误
- struts2错误消息定制和自定义类型转换
- VS2008中,VC++开发时添加自定义的消息时,发生错误的解决办法