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 (MessageUtil.MESSAGE_TEXT.equals(msgType)) { if ("1".equals(content)) { message = MessageUtil.initText(toUserName, fromUserName, MessageUtil.firstMenu()); } else if ("2".equals(content)) { message = MessageUtil.initNewsMessage(toUserName, fromUserName); } else if ("?".equals(content) || "?".equals(content)) { message = MessageUtil.initText(toUserName, fromUserName, MessageUtil.menuText()); } }else if (MessageUtil.MESSAGE_EVNET.equals(msgType)) { String eventType = map.get("Event"); if (MessageUtil.MESSAGE_SUBSCRIBE.equals(eventType)) { message = MessageUtil.initText(toUserName, fromUserName, MessageUtil.menuText()); }else if(MessageUtil.MESSAGE_CLICK.equals(eventType)){ String eventKey = map.get("EventKey"); if (eventKey.equals("11")) { message = MessageUtil.initText(toUserName, fromUserName, MessageUtil.menuText()); } }else if(MessageUtil.MESSAGE_VIEW.equals(eventType)){ String url = map.get("EventKey"); message = MessageUtil.initText(toUserName, fromUserName, url); }else if(MessageUtil.MESSAGE_SCANCODE.equals(eventType)){ String key = map.get("EventKey"); message = MessageUtil.initText(toUserName, fromUserName, key); } }else if(MessageUtil.MESSAGE_LOCATION.equals(msgType)){ String label = map.get("Label"); message = MessageUtil.initText(toUserName, fromUserName, label); } System.out.println(message); out.print(message); } catch (DocumentException e) { e.printStackTrace(); } finally { out.close(); } }
菜单创建成功,文本消息回复和view菜单工作正常,但click点击之后就显示服务器不能提供服务,位置信息的回复也不成功,求助TAT
求助,求助
我click 依然没有用
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(MessageUtil.MESSAGE_TEXT.equals(msgType)) {
if("1".equals(content)) {
message=MessageUtil.initText(toUserName, fromUserName, MessageUtil.firstText());
}else if("2".equals(content)) {
message=MessageUtil.initNewsMessage(toUserName, fromUserName);
}else if("0".equals(content)) {
message=MessageUtil.initText(toUserName, fromUserName, MessageUtil.menuText());
}
} else if(MessageUtil.MESSAGE_EVENT.equals(msgType)) {//推送事件
String eventType=map.get("Event");//事件类型
if(MessageUtil.MESSAGE_SUBSCRIBE.equals(eventType)) {
message=MessageUtil.initText(toUserName, fromUserName, MessageUtil.menuText());
}else if(MessageUtil.MESSAGE_CLICK.equals(eventType)){
String eventKey = map.get("EventKey");
if (eventKey.equals("11")) {
message = MessageUtil.initText(toUserName, fromUserName, MessageUtil.menuText());
}
}else if(MessageUtil.MESSAGE_VIEW.equals(eventType)){
String url = map.get("EventKey");
message = MessageUtil.initText(toUserName, fromUserName, url);
}else if(MessageUtil.MESSAGE_SCANCODE.equals(eventType)){
String key = map.get("EventKey");
message = MessageUtil.initText(toUserName, fromUserName, key);
}
}else if(MessageUtil.MESSAGE_LOCATION.equals(msgType)){
String label = map.get("Label");
message = MessageUtil.initText(toUserName, fromUserName, label);
}
System.out.println(message);
out.print(message);
} catch (Exception e) {
e.printStackTrace();
}finally {
out.close();
}
}
好吧 问题在于我没有把代码更新到BAE,闹了一个乌龙,导出war包然后commit然后发布就可以了,代码本身没有问题。不过,之前创建菜单时没有更新到BAE也实现了,这是为什么呀?