js+servlet实现百度搜索栏下拉框的实现
2021-03-30 22:27
阅读:680
YPE html>
标签:button extends 解析 har remove color width tps lsp
前端代码
"Content-Type" content="text/html; charset=UTF-8">s "mydiv"> "text" size=50 id="keyword" name="keyword" onkeyup="getMoreContents()" onblur="keywordblur()" onfocus="getMoreContents()"/> "button" value="百度一下" width="50px"/>"popDiv">"content_table" bgcolor="#FFFAFA" border="0" cellspacing="0" cellpadding="0"> "content_table_body">
后端代码
package cn.hogan.servlet; import com.fasterxml.jackson.databind.ObjectMapper; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.lang.invoke.CallSite; import java.util.ArrayList; import java.util.List; @WebServlet("/search") public class search extends HttpServlet { static Listlist; static { list = new ArrayList (); list.add("a"); list.add("aj"); list.add("aja"); list.add("ajax"); list.add("ba"); list.add("ajax12"); list.add("ajax123"); list.add("ajax1234"); list.add("ajax12345"); list.add("ajax123456"); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 设置编码 request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); // 获取参数 String keyword = request.getParameter("keyword"); if (keyword == null) { return; } ArrayList res = new ArrayList (); for (String str :list) { if (str.contains(keyword)){ res.add(str); } } System.out.println(new ObjectMapper().writeValueAsString(res)); new ObjectMapper().writeValue(response.getWriter(),res); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } }
js+servlet实现百度搜索栏下拉框的实现
标签:button extends 解析 har remove color width tps lsp
原文地址:https://www.cnblogs.com/hoganhome/p/12590407.html
下一篇:php获取变量所占内存大小的方法
文章来自:搜素材网的编程语言模块,转载请注明文章出处。
文章标题:js+servlet实现百度搜索栏下拉框的实现
文章链接:http://soscw.com/index.php/essay/70185.html
文章标题:js+servlet实现百度搜索栏下拉框的实现
文章链接:http://soscw.com/index.php/essay/70185.html
评论
亲,登录后才可以留言!