ssm运行时报错:No converter found for return value of type解决方法

最近在学习SpringMVC过程中,Controller能访问到接口,就是一直报错:错误日志很长,在这里只列出部分吧

No converter found for return value of type:

出错原因:返回JSON时没有引入解析JSON的相关包,解决方案:

解决方案:
pom依赖中导入fastjson依赖

<dependency>
       <groupId>com.alibaba</groupId>
       <artifactId>fastjson</artifactId>
       <version>1.2.47</version>
</dependency>

并且在applicationContext.xml文件中导入相应配置:

<context:property-placeholder location="classpath:config/application.properties" />
	<mvc:annotation-driven>
	  <mvc:message-converters register-defaults="true">
	    <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">  
	      <property name="supportedMediaTypes" value="application/json"/>
	      <property name="features">
	        <array>
	          <value>WriteMapNullValue</value>
	          <value>WriteDateUseDateFormat</value>
	        </array>
	      </property>
	    </bean>
	  </mvc:message-converters>  
	</mvc:annotation-driven>


并加上上图红色线条 标出的引用

最后maven install,重新运行即可,也许不能帮到你,但希望你尽早解决你的错误喔!

全部评论

相关推荐

01-19 12:48
门头沟学院 C++
只想搞钱的鸽子很喜欢...:混账是很多的,还有那些在自己风华正茂的年纪说风凉话讥讽那些下岗前员工的。这些人都是现在职场环境这么烂的帮凶
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务