spring mvc <mvc:annotation-driven>配置使用出现问题
来源:互联网 发布:js判断是否等于 编辑:程序博客网 时间:2024/06/06 00:51
我在使用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
0 0
- spring mvc <mvc:annotation-driven>配置使用出现问题
- spring mvc <mvc:annotation-driven>配置使用出现问题
- Spring mvc:annotation-driven
- <mvc:annotation-driven>配置
- spring中配置<mvc:default-servlet-handler />后必须配置<mvc:annotation-driven/>的问题
- spring-mvc注解(mvc:annotation-driven,JSON,配置详解)
- Spring参考手册 mvc:annotation-driven
- 【Spring MVC】<mvc:annotation-driven/>详解
- Spring MVC 中关于 mvc:annotation-driven
- spring mvc 之mvc:annotation-driven
- Spring MVC之<mvc:annotation-driven/>
- mvc:annotation-driven的使用
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- spring使用<mvc:annotation-driven/>来解决定时任务
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- “改变”之意易混单词详解
- AngularJS下拉列表动态获取
- QML做类似Android圆形头像
- Discuz!开发之消息提示函数showmessage()分析及用法实例
- vector
- spring mvc <mvc:annotation-driven>配置使用出现问题
- 基于WiFi的室内定位
- 深入理解Java内存模型——final
- 数字签名与数字证书是什么?
- Storm集群组件和编程模型
- [CentOs7]iptables防火墙安装与设置
- 特征点提取算法列表
- 十进制点分IP转换为32位二进制IP
- Java设计模式-六大原则