gistfile1.txt getParameter(String name):通过key,返回一个value。getParameterValues(String name):通过key返回一个string数组(多个值)getParameterNames():返回form表单中的所有key值。//代码@WebServlet({ "/FormSer
getParameter(String name):通过key,返回一个value。 getParameterValues(String name):通过key返回一个string数组(多个值) getParameterNames():返回form表单中的所有key值。 //代码 @WebServlet({ "/FormServlet", "/form" }) public class FormServlet extends HttpServlet { private static final long serialVersionUID = 1L;//序列化 public FormServlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/json;charset=utf-8"); PrintWriter out = response.getWriter(); //获取表单提交name 属性集合 EnumerationparamNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { String name = paramNames.nextElement(); String[] values = request.getParameterValues(name); if(values!=null && values.length>0){ StringBuilder builder = new StringBuilder(); for (int i = 0; i < values.length; i++) { builder.append(values[i]+" "); } out.println(name+" : "+builder.toString()); } } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }