OAuthProblemException{error='unsupported_response_type', description='Invalid re

OAuthProblemException{error='unsupported_response_type', description='Invalid response! Response body is not application/json encoded', uri='null', state='null', scope='null', redirectUri='null', responseStatus=0, parameters={}}


以前用了 蓝缘系统的开源代码 整合开涛兄的  OAuth2 shiro集成功能的时候 整合的时候发现 一直报上面这个错误 网上搜了很久都没找到,最后发现

<!-- 采用SpringMVC自带的JSON转换工具,支持@ResponseBody注解 -->
	<!--<ref bean="mappingJackson2HttpMessageConverter" />   -->  <!-- JSON转换器 -->
 
	<bean
		class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
		<property name="messageConverters">
			<list>
				<ref bean="mappingJackson2HttpMessageConverter" />    
		  	</list>
		</property>
	</bean>

若是不把上面的去掉那么 oathu2response返回的json被上面的拦截后处理成了这样


这样的话 paeseJson方法里 转化json就会报错

若是去掉上面的配置 获得的
protected void setBody(String body) throws OAuthProblemException {

        try {
            this.body = body;
            parameters = JSONUtils.parseJSON(body);
        } catch (JSONException e) {
            throw OAuthProblemException.error(OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE,
                "Invalid response! Response body is not " + OAuth.ContentType.JSON + " encoded");
        }
    }
这里的 body就是

这样就不会报上面那个错误了 能够对比发现两个上面那个数据被加了“//”转义符这个应该就是致使 报错的缘由 蓝缘系统里spring-mvc.xml里有一段配置是这样的 把这个去掉后 该错误就解决了,想了下应该是 该 配置拦截了 oathu2的json数据 更改了它的格式 致使 oathu2认为是非法的返回类型 从而报错 。 若是 有人遇到相似的错误能够参考 个人这个解决案例的思路。