課程
/后端開發
/Java
/通過自動回復機器人學Mybatis---基礎版
那個輸入指令和回復信息,之前是怎么設定的?
2017-04-17
源自:通過自動回復機器人學Mybatis---基礎版 2-2
正在回答
你可以看一下talk.js文件中,輸入指令放在請求的“content”屬性中的,而回復信息是在服務端直接通過Response的PrintWriter對象 直接輸出回瀏覽器的
talk.js文件中:
$.ajax({
url : $("#basePath").val() + "talk/autoReplyMessage",
type : "POST",
dataType : "text",
timeout : 10000,
success : function (data) {
appendDialog("talk_recordboxme","My賬號",content);
appendDialog("talk_recordbox","小機",data);
$("#content").val("");
render();
},
data : {"content":content}
我的Controller文件中:
@RequestMapping(value="/autoReplyMessage")
public ModelAndView getMessagesByCommand(@RequestParam("content") String command,
HttpServletResponse response) {
response.setContentType("text/html;charset=utf-8");
PrintWriter out = null;
try {
out = response.getWriter();
String reply = messageService.getMessagesByCommand(command);
out.print(reply);
out.flush();
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
希望能幫到你。
舉報
微信公眾號自動回復功能學習Mybatis,基礎教程加案例實戰方式學習
1 回答請教一下斷點查詢的問題?
1 回答斷點調試最后一步出現問題
5 回答看不懂,那位大神幫忙解答一下
1 回答獲得id值得目的
1 回答請問大神一個問題
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-04-18
你可以看一下talk.js文件中,輸入指令放在請求的“content”屬性中的,而回復信息是在服務端直接通過Response的PrintWriter對象 直接輸出回瀏覽器的
talk.js文件中:
$.ajax({
url : $("#basePath").val() + "talk/autoReplyMessage",
type : "POST",
dataType : "text",
timeout : 10000,
success : function (data) {
appendDialog("talk_recordboxme","My賬號",content);
appendDialog("talk_recordbox","小機",data);
$("#content").val("");
render();
},
data : {"content":content}
我的Controller文件中:
@RequestMapping(value="/autoReplyMessage")
public ModelAndView getMessagesByCommand(@RequestParam("content") String command,
HttpServletResponse response) {
response.setContentType("text/html;charset=utf-8");
PrintWriter out = null;
try {
out = response.getWriter();
String reply = messageService.getMessagesByCommand(command);
out.print(reply);
out.flush();
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
希望能幫到你。