Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
大气+;SpringMVC5集成_Spring_Spring Mvc_Servlets_Content Type_Atmosphere - Fatal编程技术网

大气+;SpringMVC5集成

大气+;SpringMVC5集成,spring,spring-mvc,servlets,content-type,atmosphere,Spring,Spring Mvc,Servlets,Content Type,Atmosphere,我试图运行Atmosphere(2.5.12)+SpringMVC(5.2.8),但遇到了一个问题 由于某个Spring发布了AbstractMessageConverterMethodProcessor类,writeWithMessageConverters方法已开始检查请求的响应头“Content Type”,而不是“Accept”头,以便找到合适的消息转换器 见: MediaType selectedMediaType=null; MediaType contentType=outputM

我试图运行Atmosphere(2.5.12)+SpringMVC(5.2.8),但遇到了一个问题

由于某个Spring发布了AbstractMessageConverterMethodProcessor类,writeWithMessageConverters方法已开始检查请求的响应头“Content Type”,而不是“Accept”头,以便找到合适的消息转换器

见:

MediaType selectedMediaType=null;
MediaType contentType=outputMessage.getHeaders().getContentType();
布尔值isContentTypePreset=contentType!=null&&contentType.isConcrete();
如果(isContentTypePreset){
if(logger.isDebugEnabled()){
debug(“找到”内容类型:“+contentType+””,作为响应);
}
selectedMediaType=contentType;
}
否则{
HttpServletRequest=inputMessage.getServletRequest();
List acceptableTypes=getAcceptableMediaTypes(请求);
List producibleTypes=getProducibleMediaTypes(请求、值类型、目标类型);
问题是AtmosphereFramework也设置了内容类型头。它总是“text/plain”,它是在AtmosphereFramework配置请求响应方法中设置的

见:

即使未在此处设置标头,它也是AtmosphereResponseImpl中的默认contentType,即text/html

在这种情况下,Spring无法找到正确的转换器,并引发异常:

DefaultHandlerExceptionResolver]:已解析[org.springframework.http.converter.HttpMessageNotWritableException:预设内容类型为“text/plain;charset=utf-8”的[class com.Connection]没有转换器

我正在使用web.xml中的当前配置:

 <servlet>
        <servlet-name>spring-mvc</servlet-name>
        <servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
        <init-param>
            <param-name>org.atmosphere.servlet</param-name>
            <param-value>org.springframework.web.servlet.DispatcherServlet</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.cpr.CometSupport.maxInactiveActivity</param-name>
            <param-value>3600000000</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.useStream</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.useWebSocket</param-name>
            <param-value>true</param-value>
        </init-param>
        <!-- <init-param> -->
            <!-- <param-name>org.atmosphere.useNative</param-name> -->
            <!-- <param-value>true</param-value> -->
        <!-- </init-param> -->
        <init-param>
            <param-name>org.atmosphere.cpr.supportSession</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.filter</param-name>
            <param-value>org.springframework.web.filter.DelegatingFilterProxy</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.filter.name</param-name>
            <param-value>springSecurityFilterChain</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.websocket.suppressJSR356</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.cpr.broadcastFilterClasses</param-name>
            <param-value>org.atmosphere.client.TrackMessageSizeFilter</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
    </servlet>

    <servlet-mapping>
        <servlet-name>spring-mvc</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
...........

春季mvc
org.atmosphere.cpr.servlet
org.atmosphere.servlet
org.springframework.web.servlet.DispatcherServlet
org.atmosphere.cpr.CometSupport.maxInactiveActivity
3600000000
org.atmosphere.useStream
真的
org.atmosphere.useWebSocket
真的
org.atmosphere.cpr.supportSession
真的
org.atmosphere.filter
org.springframework.web.filter.DelegatingFilterProxy
org.atmosphere.filter.name
springSecurityFilterChain
org.atmosphere.websocket.jsr356
真的
org.atmosphere.cpr.broadcasterfilterclasses
org.atmosphere.client.TrackMessageSizeFilter
1.
真的
春季mvc
*.做
...........
我的配置正确吗? 是否所有请求都必须通过public AtmosphereFramework configureRequestResponse(AtmosphereRequest req,AtmosphereResponse res)方法? 有没有办法让Spring在AtmosphereResponseImpl中忽略内容类型标题

 <servlet>
        <servlet-name>spring-mvc</servlet-name>
        <servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
        <init-param>
            <param-name>org.atmosphere.servlet</param-name>
            <param-value>org.springframework.web.servlet.DispatcherServlet</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.cpr.CometSupport.maxInactiveActivity</param-name>
            <param-value>3600000000</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.useStream</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.useWebSocket</param-name>
            <param-value>true</param-value>
        </init-param>
        <!-- <init-param> -->
            <!-- <param-name>org.atmosphere.useNative</param-name> -->
            <!-- <param-value>true</param-value> -->
        <!-- </init-param> -->
        <init-param>
            <param-name>org.atmosphere.cpr.supportSession</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.filter</param-name>
            <param-value>org.springframework.web.filter.DelegatingFilterProxy</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.filter.name</param-name>
            <param-value>springSecurityFilterChain</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.websocket.suppressJSR356</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>org.atmosphere.cpr.broadcastFilterClasses</param-name>
            <param-value>org.atmosphere.client.TrackMessageSizeFilter</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
    </servlet>

    <servlet-mapping>
        <servlet-name>spring-mvc</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
...........