我在 jsp 页面中有一个 html 表单,提交时将转到 servlet ..在 servlet 中执行函数后,我再次将它重定向到同一个 jsp 页面,从该页面调用它并显示成功消息相同的 jsp 页面,但我不知道该怎么做 ...
这是我的jsp表单代码..
<form action="CallTimer" method="GET">
<label class="button2">Set Date: </label>
<input type="text" name="date" id="date">
<label class="button2">Set Hour </label>
<input type="text" name="hour" id="hour">
<label class="button2">Set Minute: </label>
<input type="text" name="minute" id="minute">
<input type="Submit" name="Submit" value="Submit" id="Submit">
<br/><br/>
<label class="button2">Set File-Path: </label>
<input type="text" name="filepath" id="filepath">
</form>
这是我的 servlet 重定向代码。
response.sendRedirect("Automail.jsp");
最佳答案
在 Servlet 中:
// You need to set value in session for redirection.
session.setAttribute("msg","Success");
response.sendRedirect("Automail.jsp");
在 Automail.jsp
${msg}
关于java - 如何在 page.redirect 从 servlet 到 jsp 上显示成功消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19972073/