NutzCN Logo
问答 微信公众号关注回调报错,请大神帮看看!
发布于 16天前 作者 qq_6d75074b 75 次浏览 复制 上一个帖子 下一个帖子
标签:


package cn.wx; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import org.nutz.ioc.impl.PropertiesProxy; import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.mvc.View; import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Filters; import org.nutz.weixin.impl.WxApi2Impl; import org.nutz.weixin.spi.WxApi2; import org.nutz.weixin.util.Wxs; @At("/weixin") @IocBean(create = "init") public class WeixinModule { // 并不要求你继承任何东西 /* * wxHandler是被动请求的主要处理类, 里面写的1234567890就是"接口配置信息"里面提到的"token", */ @Inject protected DefaultWxHandler wxHandler; @Inject protected WxApi2 wxApi2; @Inject protected PropertiesProxy conf; public void init() { WxApi2Impl wxApi2 = new WxApi2Impl(); wxApi2.configure(conf, "weixin."); // 从配置信息里面读取各种需要的参数 this.wxApi2 = wxApi2; } // protected WxHandler wxHandler = new BasicWxHandler("1234567890"); @At // 拼起来的全路径就是 /weixin/msgin @Filters public View msgin(HttpServletRequest req) throws IOException { System.out.print(11111); return Wxs.handle(wxHandler, req, "default"); // 最后面的default,可以不写,只是个标识符. } /** * 新增数据 * * @param :Status * @return:Object */ @At @Filters public String getAccessToken() { return wxApi2.getAccessToken(); } }
2019-05-10 00:43:45,888 org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:101) DEBUG - Found mapping for [POST] path=/weixin/msgin/ : WeixinModule.msgin(WeixinModule.java:44)
2019-05-10 00:43:45,889 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'weixinModule'<class cn.wx.WeixinModule>
2019-05-10 00:43:45,890 cn.core.mvc.LogTimeProcessor.process(LogTimeProcessor.java:28) DEBUG - [POST]URI=/alfx/weixin/msgin/ 1ms
2019-05-10 00:43:45,890 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) WARN  - Error@/weixin/msgin/ :
org.nutz.json.JsonException: !Json syntax error nearby [row:1,col:1 char '<'], reason: 'Unexpect String = <xml><ToUserName><![CDATA[gh_db3a698b1ae0]]></ToUserName>
<FromUserName><![CDATA[ofw7L1dqcaJ5mPmxxnISprWCiVWU]]></FromUserName>
<CreateTime>1557420226</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[subscribe]]></Event>
<EventKey><![CDATA[]]></EventKey>
</xml>'
	at org.nutz.json.impl.JsonTokenScan.readObject(JsonCompileImplV2.java:295)
	at org.nutz.json.impl.JsonTokenScan.read(JsonCompileImplV2.java:351)
	at org.nutz.json.impl.JsonCompileImplV2.parse(JsonCompileImplV2.java:26)
	at org.nutz.json.Json.fromJson(Json.java:42)
	at org.nutz.mvc.adaptor.JsonAdaptor.getReferObject(JsonAdaptor.java:41)
	at org.nutz.mvc.adaptor.AbstractAdaptor.adapt(AbstractAdaptor.java:226)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:28)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.core.mvc.LogTimeProcessor.process(LogTimeProcessor.java:23)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at cn.core.mvc.MyNutFilter.doFilter(MyNutFilter.java:37)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at cn.core.util.XFilter.doFilter(XFilter.java:25)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
1 回复

MainModule配了json适配器吧

msgin方法加上

@AdaptBy(type=VoidAdaptor.class)

添加回复
请先登陆
回到顶部