private static Logger logger = Logger.getLogger(UserDao.class);
2019-03-27 11:39:54,147 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) WARN - Error@/weixin/msgin :
java.lang.NullPointerException
at org.nutz.weixin.repo.com.qq.weixin.mp.aes.WXBizMsgCrypt.(WXBizMsgCrypt.java:57)
at org.nutz.weixin.impl.BasicWxHandler.getMsgCrypt(BasicWxHandler.java:39)
at org.nutz.weixin.util.Wxs.handle(Wxs.java:688)
at net.wendal.nutzbook.weinModel.WeixinModule.msgin(WeixinModule.java:26)
at net.wendal.nutzbook.weinModel.WeixinModule$FM$msgin$b806526ae658790edc3fc063949c9d61.invoke(WeixinModule.java)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:30)
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.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 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
春天的风 13:24:15
import org.apache.log4j.Logger;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.weixin.bean.WxInMsg;
import org.nutz.weixin.bean.WxOutMsg;
import org.nutz.weixin.impl.BasicWxHandler;
import org.nutz.weixin.util.Wxs;
import net.wendal.nutzbook.dao.UserDao;
@IocBean(create="init", name="WxHandler")
public class DefaultWxHandler extends BasicWxHandler {
private static Logger logger = Logger.getLogger(UserDao.class);
@Inject
protected PropertiesProxy conf; // 注入配置信息加载类
public void init() {
// 将读取 weixin.token/weixin.aes/weixin.appid, 他们通常会写在weixin.properties或从数据库读取.
configure(conf, "weixin.");
// 如果你不知道conf是啥, 完全搞不清楚状况,
// 请将protected PropertiesProxy conf注释掉,configure也注释掉
// 把下面这行取消注释.
// token = "1234567890";
}
public WxOutMsg text(WxInMsg msg) {
logger.info(msg.getContent());
if ("1".equals(msg.getContent())) {
return Wxs.respText("广告法说不能自称第一");
}
else if ("2".equals(msg.getContent())) {
return Wxs.respText("就是这么2");
}
return super.text(msg);
}
}
import javax.servlet.http.HttpServletRequest;
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.weixin.util.Wxs;
import net.wendal.nutzbook.WxHandler.DefaultWxHandler;
@IocBean
@At("/weixin")
public class WeixinModule { // 并不要求你继承任何东西
/*
wxHandler是被动请求的主要处理类, 里面写的1234567890就是"接口配置信息"里面提到的"token",
*/
@Inject
protected DefaultWxHandler defaultWxHandler;
@At // 拼起来的全路径就是 /weixin/msgin
public View msgin(HttpServletRequest req) throws IOException {
return Wxs.handle(defaultWxHandler, req, "default"); // 最后面的default,可以不写,只是个标识符.
}
}