慕粉4016800
2017-03-07 12:22
/** * 对话页的初始化控制 InitTalkServlet.java */ @SuppressWarnings("serial") public class InitTalkServlet extends HttpServlet { @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //设置编码 req.setCharacterEncoding("utf-8"); //页面跳转 req.getRequestDispatcher("/WEB-INF/jsp/front/talk.jsp").forward(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { this.doGet(req, resp); } }
talk.jsp
<!DOCTYPE html> <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>微信公众号</title> <!--讨论区滚动条begin--> <link rel="stylesheet" type="text/css" href="<%=basePath %>resources/css/jscrollpane1.css" /> <script src="<%= basePath %>resources/js/common/jquery-1.8.0.min.js" type="text/javascript"></script> <!-- the mousewheel plugin --> <script type="text/javascript" src="<%=basePath %>resources/js/common/jquery.mousewheel.js"></script> <!-- the jScrollPane script --> <script type="text/javascript" src="<%=basePath %>resources/js/common/jquery.jscrollpane.min.js"></script> <script type="text/javascript" src="<%=basePath %>resources/js/common/scroll-startstop.events.jquery.js"></script> <!--讨论区滚动条end--> <script type="text/javascript" src="<%=basePath %>resources/js/front/talk.js"></script> </head> <body> <input type="hidden" value="<%=basePath %>" id="basePath"/> <br/> <div class="talk"> <div class="talk_title"><span>正在与公众号对话</span></div> <div class="talk_record"> <div id="jp-container" class="jp-container"> </div> </div> <div class="talk_word"> <input class="add_face" id="facial" type="button" title="添加表情" value="" /> <input id="content" class="messages emotion" /> <input class="talk_send" onclick="send();" type="button" title="发送" value="发送" /> </div> </div> <div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';"></div> </body> </html>
现在第一条对话显示了呢,不过汉字都是乱码,发送按钮还是没作用的 呢
ajax里面使用的数据传送方式是post,你看下你的后台servlet的方法是不是doPost,就是doPost方法里面处理事务。
是怎么解决的?我发送按钮也发送不了东西
/** * 对话页的初始化控制 InitTalkServlet.java */ @SuppressWarnings("serial") public class InitTalkServlet extends HttpServlet { @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //设置编码 req.setCharacterEncoding("utf-8"); //页面跳转 req.getRequestDispatcher("/WEB-INF/jsp/front/talk.jsp").forward(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { this.doGet(req, resp); } }
贴出关键代码。
通过自动回复机器人学Mybatis---基础版
107413 学习 · 831 问题
相似问题