jsp 獲取當前請求的值
阿新 • • 發佈:2019-02-14
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> This is my JSP page. <br> <form name="previousRequestForm" id="previousRequestForm" action="T" method="post"> <input name="useName" value="1111"/> <button type="submit" value="submit"></button> </form> <% Map parameterMap=request.getParameterMap(); System.out.print(parameterMap); for(Iterator iterator=parameterMap.entrySet().iterator();iterator.hasNext();){ Map.Entry entry=(Map.Entry)iterator.next(); String name=entry.getKey().toString(); String[] values=(String[])entry.getValue(); out.print(name+"-------------"+Arrays.toString(values)); } %> </body> </html>
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//這樣取不到值!
response.sendRedirect("b.jsp");
//request.getRequestDispatcher("/b.jsp").forward(request, response);
}