当前位置: 首页>>代码示例>>Java>>正文


Java RawView类代码示例

本文整理汇总了Java中org.nutz.mvc.view.RawView的典型用法代码示例。如果您正苦于以下问题:Java RawView类的具体用法?Java RawView怎么用?Java RawView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RawView类属于org.nutz.mvc.view包,在下文中一共展示了RawView类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import org.nutz.mvc.view.RawView; //导入依赖的package包/类
/**
 * 用一个wxHandler处理对应的用户请求
 */
public static View handle(WxHandler wxHandler, HttpServletRequest req, String key) throws IOException {
	if (wxHandler == null) {
		log.info("WxHandler is NULL");
		return HttpStatusView.HTTP_502;
	}
	if (!wxHandler.check(req.getParameter("signature"), req.getParameter("timestamp"), req.getParameter("nonce"), key)) {
		log.info("token is invalid");
		return HttpStatusView.HTTP_502;
	}
	if ("GET".equalsIgnoreCase(req.getMethod())) {
		log.info("GET? return echostr=" + req.getParameter("echostr"));
		return new ViewWrapper(new RawView(null), req.getParameter("echostr"));
	}
	WxInMsg in = Wxs.convert(req.getInputStream());
	in.setExtkey(key);
	WxOutMsg out = wxHandler.handle(in);
	if (out != null)
		Wxs.fix(in, out);
	return new ViewWrapper(WxView.me, out);
}
 
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:24,代码来源:Wxs.java

示例2: handle

import org.nutz.mvc.view.RawView; //导入依赖的package包/类
/**
 * 用一个wxHandler处理对应的用户请求
 */
public static View handle(WxHandler wxHandler, HttpServletRequest req, String key)
        throws IOException {
    if (wxHandler == null) {
        log.info("WxHandler is NULL");
        return HttpStatusView.HTTP_502;
    }
    String signature = req.getParameter("signature");
    String timestamp = req.getParameter("timestamp");
    String nonce = req.getParameter("nonce");
    String msg_signature = req.getParameter("msg_signature");
    String encrypt_type = req.getParameter("encrypt_type");
    if (!wxHandler.check(signature, timestamp, nonce, key)) {
        log.info("token is invalid");
        return HttpStatusView.HTTP_502;
    }
    if ("GET".equalsIgnoreCase(req.getMethod())) {
        String echostr = req.getParameter("echostr");
        log.info("GET? return echostr=" + echostr);
        return new ViewWrapper(new RawView(null), echostr);
    }
    String postData = Streams.readAndClose(new InputStreamReader(req.getInputStream(),
                                                                 Encoding.CHARSET_UTF8));

    if ("aes".equals(encrypt_type)) {
        WXBizMsgCrypt msgCrypt = wxHandler.getMsgCrypt();
        try {
            // 若抛出Illegal key size,请更新JDK的加密库为不限制长度
            postData = msgCrypt.decryptMsg(msg_signature, timestamp, nonce, postData);
        }
        catch (AesException e) {
            return new HttpStatusView(403);
        }
    }
    WxInMsg in = Wxs.convert(postData);
    in.setExtkey(key);
    WxOutMsg out = wxHandler.handle(in);
    if (out != null) {
        Wxs.fix(in, out);
    }
    return new ViewWrapper(WxView.me, out);
}
 
开发者ID:nutzam,项目名称:nutzwx,代码行数:45,代码来源:Wxs.java


注:本文中的org.nutz.mvc.view.RawView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。