jsp源码实例2(获取表单参数)_MySQL
Jun 01, 2016 pm 02:07 PM package coreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
/** Shows all the parameters sent to the servlet via either
* GET or POST. Specially marks parameters that have
* no values or multiple values.
*
* Taken from Core Servlets and JavaServer Pages
* from Prentice Hall and Sun Microsystems Press,
* http://www.coreservlets.com/.
* © 2000 Marty Hall; may be freely used or adapted.
*/
public class ShowParameters extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Reading All Request Parameters";
out.println(ServletUtilities.headWithTitle(title) +
"
"
" + title + "
\n" +"
Parameter Name | Parameter Value(s)"); Enumeration paramNames = request.getParameterNames(); while(paramNames.hasMoreElements()) { String paramName = (String)paramNames.nextElement(); out.print(" |
---|---|
" + paramName + "\n | "); String[] paramValues = request.getParameterValues(paramName); if (paramValues.length == 1) { String paramValue = paramValues[0]; if (paramValue.length() == 0) out.println("No Value"); else out.println(paramValue); } else { out.println("
for(int i=0; i } } out.println(" |

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

C++ function parameter type safety check

How to install dual SIM on Realme 12 Pro?

How to display the source code of PHP code in the browser without being interpreted and executed?

The relationship between the number of Oracle instances and database performance

Advanced usage of reference parameters and pointer parameters in C++ functions

How to adjust the parameters of the beauty camera to take better-looking photos. Reference for the best parameters of the beauty camera.
