用http://localhost:8080/testQueryString/chaXunZiFuChuan?name=liumingyuan&mother=zhangxiaoxue访问,输出:
name=liumingyuan&mother=zhangxiaoxue
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class chaXunZiFuChuan
*/
@WebServlet("/chaXunZiFuChuan")
public class chaXunZiFuChuan extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public chaXunZiFuChuan() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String gouGou=request.getQueryString();
System.out.println(gouGou);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
}
源代码:
http://pan.baidu.com/share/link?shareid=2524349476&uk=3878681452