本文整理匯總了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);
}
示例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);
}