使用的spring 版本是 4.20 在springmvc配置 报错很奇怪。。
该错误是因为:
1、内嵌jetty在运行时会锁定静态资源;因此在运行过程中不能删除静态资源;
2、问题的根源是启动了多个jetty实例,但是实际没有报端口冲突,可以检查任务管理器看是否有多个java/javaw进程在运行,如果是杀掉进程然后重试。
配置这个没?
<mvc:resourcesmapping=""location=""/>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<!--配置设配器由于配置过多的handler不方便mvc标签使用可以扫面包下面所有的Controller--><!--扫描Controller--><context:component-scanbase-package="com.sandy.ssm.controller"></context:component-scan><!--注解处理器映射器--><!--conversion-service转换器--><mvc:annotation-drivenconversion-service="conversionService"></mvc:annotation-driven><!--静态资源访问--><mvc:resourceslocation="/img/"mapping="/img/**"/><mvc:resourceslocation="/js/"mapping="/js/**"/><!--视图解析器--><beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"><!--配置视图前端--><propertyname="prefix"value="/WEB-INF/jsp/"/><propertyname="suffix"value=".jsp"/></bean><!--自定义参数绑定--><beanid="conversionService"class="org.springframework.format.support.FormattingConversionServiceFactoryBean"><!--转换器--><propertyname="converters"><list><!--日期类型转换--><beanclass="com.sandy.ssm.controller.converter.CustomDateConverter"/></list></property></bean><!--全局异常处理器--><beanclass="com.sandy.ssm.exception.ExceptionHandler"></bean><!--文件上传--><beanid="multipartResolver"class="org.springframework.web.multipart.commons.CommonsMultipartResolver"><!--设置上传文件的最大尺寸为5MB--><propertyname="defaultEncoding"value="utf-8"></property><propertyname="maxUploadSize"value="5242880"></property></bean><!--拦截器-->
/mvc:annotation-driven
这些换成下面的试试
第一次启动会显示下面的错误但是能正常访问我就是想知道这个报错是什么问题第二次访问就没有问题了。、
EBUG[http-8080-1]-OriginalConversionServiceattemptfailed-ignoredsincePropertyEditorbasedconversioneventuallysucceeded
org.springframework.core.convert.ConversionFailedException:Failedtoconvertfromtypejava.util.ArrayList<?>totypejava.util.Listforvalue'[/js/]';nestedexceptionisorg.springframework.core.convert.ConverterNotFoundException:Noconverterfoundcapableofconvertingfromtypejava.lang.Stringtotypeorg.springframework.core.io.Resource
atorg.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41)
atorg.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:169)
atorg.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:161)
atorg.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:450)
atorg.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:496)
atorg.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:490)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1437)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1396)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1132)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
atorg.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:647)
atorg.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:598)
atorg.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:661)
atorg.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:517)
atorg.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:458)
atorg.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)
atjavax.servlet.GenericServlet.init(GenericServlet.java:212)
atorg.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1213)
atorg.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:827)
atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
atorg.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
atjava.lang.Thread.run(Thread.java:662)
Causedby:org.springframework.core.convert.ConverterNotFoundException:Noconverterfoundcapableofconvertingfromtypejava.lang.Stringtotypeorg.springframework.core.io.Resource
atorg.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:276)
atorg.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:172)
atorg.springframework.core.convert.support.CollectionToCollectionConverter.convert(CollectionToCollectionConverter.java:74)
atorg.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:35)
...36more
添加这个看看
<mvc:default-servlet-handler/>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。