JSPì?×a·?ê?
ò?£oRequestDispatcher.forward()
ê??ú·t???÷???e×÷ó?£?μ±ê1ó?forward()ê±£?Servlet engine ′?μYHTTP???ó′óμ±?°μ?Servlet or jsp μ?áííaò???Servlet JSP ?ò??í¨HTML???t
?éò???DD2?êy′?μY è?£o
RequestDispatcher rd = context.getRequestDispatcher("/jsp/forward.jsp?name=zhangsan");
RequestDispatcher rd = context.getRequestDispatcher("/F?name=jingjing");
???¨?òoó?ˉàà?÷μ??·à?URL2?±?
<p> ày£o?úservlet?D??DD???¨?ò</p><p> </p><pre class="java" name="code">public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
ServletContext context = getServletContext();
//forward()μ?jsp
RequestDispatcher rd = context.getRequestDispatcher("/jsp/forward.jsp?name=zhangsan");
//forward()μ?á?ò???servlet F?aservletμ?url-pattern servletò2?é??DD2?êy′?μY
//RequestDispatcher rd = context.getRequestDispatcher("/F?name=jingjing");
request.setAttribute("info", "hello"); //2?êy′?μY
rd.forward(request, response);
}
?·???°±?D?′?óD"/" £?"/"μ?o?ò?ê±??????3? ·??ò±¨è???òì3££o
java.lang.IllegalArgumentException: Path F does not start with a "/" character
com.org.MyServlet.doGet(MyServlet.java:31)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
?úforward.jsp?Dè?μ?2?êy?a£o
String name = request.getParameter("name");
?úservlet?Dè?μ?2?êy?a£o
<pre class="java" name="code"> String name = request.getParameter("name");
相关新闻>>
- 发表评论
-
- 最新评论 更多>>