Servlet。。。。。。。。。。。。。。。。。
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String paramInfo = request.getParameter("paramInfo");
System.out.println(paramInfo);
//…………数据处理
request.setAttribute("autoCompleteList", list);
request.getRequestDispatcher("./js/autoComplete.jsp").forward(request,
response);
}
体现mvc的思想,jQuery获得的返回页面是text/xml格式
<%@ page language="java" pageEncoding="utf-8" contentType="text/xml; charset=utf-8"%> <%@taglib prefix="html" uri="http://struts.apache.org/tags-html" %> <%@taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %> <%@taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %> <keys> <logic:notEmpty name="autoCompleteList" scope="request"> <logic:iterate id="liststr" name="autoCompleteList" scope="request"> <key><bean:write name="liststr"/></key> </logic:iterate> </logic:notEmpty> </keys>
本文介绍了一个使用Servlet处理HTTP请求的示例,并展示了如何通过jQuery获取返回的数据。具体包括从请求中读取参数、处理数据并将其转发到特定的JSP页面。此外,还介绍了如何在JSP页面上使用Struts标签库来遍历并展示数据。
199

被折叠的 条评论
为什么被折叠?



