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

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

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

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

IT小公舉 2017-04-10 18:14:54
是按照慕課網(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 blocke.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);}}
查看完整描述

2 回答

?
qq_流年之殤_0

TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超1個(gè)贊

我也遇到這個(gè)問題了,你解決了嗎?

查看完整回答
1 反對 回復(fù) 2018-05-01
?
勝利女神在微笑

TA貢獻(xiàn)67條經(jīng)驗(yàn) 獲得超59個(gè)贊

TextMessage這個(gè)類你創(chuàng)建了嗎,導(dǎo)包導(dǎo)錯(cuò)了

查看完整回答
反對 回復(fù) 2017-08-03
  • 2 回答
  • 0 關(guān)注
  • 1576 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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