第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Java實(shí)現(xiàn)微信的自動(dòng)回復(fù)總是報(bào)錯(cuò)

Java實(shí)現(xiàn)微信的自動(dòng)回復(fù)總是報(bào)錯(cuò)

IT小公舉 2017-04-09 20:19:21
是按照慕課網(wǎng)的教程抄的代碼,可是不知道為什么總是報(bào)錯(cuò)Servlet.service() for servlet [weixinServlet] in context with path [/One] threw exception [Servlet execution threw an exception] with root causejava.lang.NoClassDefFoundError: javax/jms/TextMessage錯(cuò)誤出現(xiàn)在這一行我把weixinservlet類和checkutil還有messageutil類發(fā)在下面了,求大牛指點(diǎn)錯(cuò)在哪里了↓↓下面是WeixinServlet類的dopost方法protected void doPost(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException{ req.setCharacterEncoding("UTF-8"); resp.setCharacterEncoding("UTF-8"); PrintWriter out ?= resp.getWriter(); try { Map<String, String> map = MessageUtil.xmlToMap(req); String fromUserName = map.get("FromUserName"); String toUserName = map.get("ToUserName"); String msgType = map.get("MsgType"); String content = map.get("Content"); String message = null; if("text".equals(msgType)){ TextMassage text ?= new TextMassage(); text.setFromUserName(toUserName); text.setToUserName(fromUserName); text.setMsgType("text"); text.setContent("您發(fā)送的消息是"+content); message = MessageUtil.textMessageToXml(text); } out.print(message); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ out.close(); } }↓↓這是checkutil類package com.imooc.util;import java.security.MessageDigest;import java.util.Arrays;public class CheckUtil { public static final String token = "imooc"; public static boolean checkSignature(String signature,String timestamp,String nonce){ String[] arr=new String[]{token,timestamp,nonce}; Arrays.sort(arr); StringBuffer content = new StringBuffer(); for(int i = 0;i<arr.length;i++){ content.append(arr[i]); } String temp = getSha1(content.toString()); return temp.equals(signature); } public static String getSha1(String str){ ? ? ? ?if(str==null||str.length()==0){ ? ? ? ? ? ?return null; ? ? ? ?} ? ? ? ?char hexDigits[] = {'0','1','2','3','4','5','6','7','8','9', ? ? ? ? ? ? ? ?'a','b','c','d','e','f'}; ? ? ? ?try { ? ? ? ? ? ?MessageDigest mdTemp = MessageDigest.getInstance("SHA1"); ? ? ? ? ? ?mdTemp.update(str.getBytes("UTF-8")); ? ? ? ? ? ?byte[] md = mdTemp.digest(); ? ? ? ? ? ?int j = md.length; ? ? ? ? ? ?char buf[] = new char[j*2]; ? ? ? ? ? ?int k = 0; ? ? ? ? ? ?for (int i = 0; i < j; i++) { ? ? ? ? ? ? ? ?byte byte0 = md[i]; ? ? ? ? ? ? ? ?buf[k++] = hexDigits[byte0 >>> 4 & 0xf]; ? ? ? ? ? ? ? ?buf[k++] = hexDigits[byte0 & 0xf]; ? ? ? ? ? ? ? ? ?} ? ? ? ? ? ?return new String(buf); ? ? ? ?} catch (Exception e) { ? ? ? ? ? ?// TODO: handle exception ? ? ? ? ? ?return null; ? ? ? ?} } }?↓↓這是messageutil類package com.imooc.util;import java.io.IOException;import java.io.InputStream;import java.util.HashMap;import java.util.List;import java.util.Map;import javax.jms.TextMessage;import javax.servlet.http.HttpServletRequest;import org.dom4j.Document;import org.dom4j.DocumentException;import org.dom4j.Element;import org.dom4j.io.SAXReader;import com.immoc.po.TextMassage;import com.thoughtworks.xstream.XStream;public class MessageUtil { public static Map<String,String>xmlToMap(HttpServletRequest request)throws IOException,DocumentException{ Map<String,String>map=new HashMap<String, String>(); SAXReader reader = new SAXReader(); InputStream ins = request.getInputStream(); Document doc = reader.read(ins); Element root = doc.getRootElement(); List<Element> list = root.elements(); for(Element e:list){ map.put(e.getName(),e.getText()); } ins.close(); return map; } public static String textMessageToXml(TextMassage text){ XStream xstream = new XStream(); xstream.alias("xml", text.getClass()); return ?xstream.toXML(text); } };
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關(guān)注
  • 1779 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)