spring mvc mvc:annotation

我在使用converter进行全局的日期类型转换。

1。写converer

public class CustomDateConverter implements Converter<String, Date> {public Date convert(String s) {try {return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(s);} catch (ParseException e) {e.printStackTrace();}return null;}}然后修改spingmvc.xml配置文件:

<!– 配置日期转换器 注解驱动 –><mvc:annotation-driven conversion-service="conversionService"/><!– 配置日期转换器 –><bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"><property name="converters"><list><bean class="xyz.zhulei.core.controller.converter.CustomDateConverter"/></list></property></bean>

但是运行的时候出显了这个错误:

HTTP Status 500 – Servlet.init() for servlet back threw exception

root cause

org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 68; cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 ‘mvc:annotation-driven’ 的声明。com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)

原因在于,我引用spingmvc.xml中的头文件时3.0版本的xsd,,下面这个注解时3.1才有的,所以我把xsd文件的版本换成4.0的就好了!mvc:annotation-driven

版权声明:本文为博主原创文章,未经博主允许不得转载。

是不是因为心痛的麻木了,我才笑得最美丽。

spring mvc mvc:annotation

相关文章:

你感兴趣的文章:

标签云: