2 mooner guo Mooner_guo 于 2015.06.26 20:00 提问

使用Springmvc开发微信公众号数据传输问题

返回给微信服务器的XML格式的字符串,发现在公网Linux服务器中,tomcat的catalina.out文件打印的该字符串少了<![CDATA[toUser]]>
<![CDATA[FromUser]]>
123456789
这几行标签,手机微信提示该订阅号无法提供服务,请稍后再试。
该问题找了好久都找不出原因。是springmvc的数据传输有问题吗?
我贴一下springmvc.xml配置,求帮忙解答!!~

<!-- 加载controller的时候,不加载service,因为此时事物并未生效,若此时加载了service,那么事物无法对service进行拦截 -->
<context:component-scan base-package="org.jeecgframework.web.*,weixin.*">
    <context:exclude-filter type="annotation"
        expression="org.springframework.stereotype.Service" />
</context:component-scan>

<!-- ApplicationContext -->
<bean class="org.jeecgframework.core.util.ApplicationContextUtil"></bean>

<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
<bean id="mappingJacksonHttpMessageConverter"
    class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
    <property name="supportedMediaTypes">
        <list>
            <value>text/html;charset=UTF-8</value>
        </list>
    </property>
</bean>
<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射, 配置一个基于注解的定制的WebBindingInitializer,解决日期转换问题,方法级别的处理器映射 -->
<bean
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="cacheSeconds" value="0" />
    <property name="messageConverters">
        <list>
            <ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->
        </list>
    </property>
    <property name="webBindingInitializer">
        <bean class="org.jeecgframework.core.interceptors.MyWebBinding" />
    </property>
</bean>
<!-- 默认的视图解析器 在上边的解析错误时使用 (默认使用html)- -->
<bean id="defaultViewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver"
    p:order="3">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" />
    <property name="contentType" value="text/html" />
    <property name="prefix" value="/webpage/" />
    <property name="suffix" value=".jsp" />
</bean>
<bean id="multipartResolver"
    class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
    p:defaultEncoding="UTF-8">
    <property name="maxUploadSize">
        <value>104857600</value>
    </property>
    <property name="maxInMemorySize">
        <value>4096</value>
    </property>
</bean>

<!-- Bean解析器,级别高于默认解析器,寻找bean对象进行二次处理 -->
<bean id="beanNameViewResolver"
      class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0">
</bean>
<!-- Excel 处理 根据用户输入进行对象处理 -->
<bean id="jeecgExcelView" class="org.jeecgframework.poi.excel.view.JeecgSingleExcelView" />
<!-- 方言 -->
<bean id="dialect"
    class="org.jeecgframework.core.common.hibernate.dialect.DialectFactoryBean">
    <property name="dbType" value="${jdbc.dbType}" />
</bean>
<!-- 异常处理类 -->
<bean id="exceptionHandler"
    class="org.jeecgframework.core.common.exception.MyExceptionHandler" />
<!-- 系统错误转发配置[并记录错误日志] -->
<bean
    class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    <property name="defaultErrorView" value="500"></property>   <!-- 默认为500,系统错误(error.jsp) -->
    <property name="defaultStatusCode" value="404"></property>
    <property name="statusCodes"><!-- 配置多个statusCode -->
        <props>
            <prop key="error">500</prop>  <!-- error.jsp -->
            <prop key="error1">404</prop>    <!-- error1.jsp -->
        </props>
    </property>
    <property name="exceptionMappings">
        <props>
            <!-- 这里你可以根据需要定义N多个错误异常转发 -->
            <prop key="java.sql.SQLException">dbError</prop> <!-- 数据库错误(dbError.jsp) -->
            <prop key="org.springframework.web.bind.ServletRequestBindingException">bizError</prop> <!-- 参数绑定错误(如:必须参数没传递)(bizError.jsp) -->
            <prop key="java.lang.IllegalArgumentException">bizError</prop>  <!-- 参数错误(bizError.jsp) -->
            <prop key="org.springframework.validation.BindException">bizError</prop>  <!-- 参数类型有误(bizError.jsp) -->
            <prop key="java.lang.Exception">unknowError</prop>  <!-- 其他错误为'未定义错误'(unknowError.jsp) -->
        </props>
    </property>
</bean>
<!-- 拦截器 -->
<mvc:interceptors>
    <mvc:interceptor>
        <mvc:mapping path="/**" />
        <bean class="org.jeecgframework.core.interceptors.EncodingInterceptor" />
    </mvc:interceptor>
    <mvc:interceptor>
        <mvc:mapping path="/**" />
        <bean class="org.jeecgframework.core.interceptors.AuthInterceptor">
            <property name="excludeUrls">
                <list>
                    <value>loginController.do?goPwdInit</value>
                    <value>loginController.do?pwdInit</value>
                    <value>loginController.do?login</value>
                    <value>loginController.do?checkuser</value>
                    <value>repairController.do?repair</value>
                    <value>repairController.do?deleteAndRepair</value>
                    <value>cmsMenuController.do?index</value>
                    <value>cmsArticleController.do?cmsArticleListShow</value>
                    <value>cmsArticleController.do?datagridwx</value>
                    <value>cmsArticleController.do?cmsArticleShow</value>
                    <value>cmsController.do?goPage</value>
                    <value>cmsController.do?getMenuList</value>
                    <value>wechatController.do?wechat</value>
                    <value>zpController.do?iscontinue</value>
                    <value>zpController.do?saveZpPrize</value>
                    <value>zpController.do?getZpPize</value>
                    <value>zpController.do?saverecord</value>
                    <value>zpController.do?ggl_new</value>
                    <value>zpController.do?ggl</value>
                    <value>zpController.do?zp</value>
                    <value>zpController.do?goZhuanpan</value>
                    <value>weixinCmsStyleController.do?upload</value>
                    <value>newsItemController.do?newscontent</value>
                    <!-- 保存用户 -->
                    <value>userController.do?saveUser</value>
                </list>
            </property>
        </bean>
    </mvc:interceptor>
</mvc:interceptors>

1个回答

wojiushiwo945you
wojiushiwo945you   Ds   Rxr 2015.11.30 10:54

检查下你的controller代码,在拼接XML回复信息的地方是否正确拼接了呢?

Csdn user default icon
上传中...
上传图片
插入图片