當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。