提交表单数据后如何重新加载JSP页面
问题描述:
只是想知道如何在表单中提交数据后刷新jsp页面.
Just wondering how to refresh the jsp page after submitting data in the form.
if (request.getParameter("key") != null){
if (request.getParameter("value") != null){
Cookie cookie = new Cookie(request.getParameter("key"), request.getParameter("value"));
response.addCookie(cookie);
}
}
我应该在response.addCookie之后添加一些内容吗?
should I add something following the response.addCookie ?
答
假设您从表单提交到SubmitServlet
,然后使用RequestDispatcher
或response.sendRedirect
suppose you submit to SubmitServlet
from the form, then redict to the same JSP from it using RequestDispatcher
or response.sendRedirect