JSP中如何获取请求其他页面的源页面
我有一个表单
<form name=frmMain method="POST" action="processUpload.jsp" enctype="multipart/form-data">
<p align="center"><table border="1" align="center" width="90%" cellspacing="0" bordercolordark="white" bordercolorlight="black">
<tr>
<td width="261" height="111">
<table border="0" cellspacing="0px" bordercolor="#B9B9B9" id="AutoNumber1" style="border-collapse: collapse" cellpadding="0px" align="left" width="100%" height="114">
<tr>
<td width="264" height="25" colspan="2" bgcolor="#FCDCA0">
<p align="left"><b><font face="Tahoma" size="2"> </font><font face="Tahoma">Upload you excel file</font></b></p>
</td>
</tr>
<tr>
<td width="15px" height="23">
<p align="right" style="vertical-align: middle"><font face="Verdana" size="2"><b> File: </b></font> </td>
<td width="300px" height="23">
<p align="left"> <input type="file" name="excelfile" size="40" >
</td>
</tr>
<tr>
<td width="15px" height="28">
<p align="center"></td>
<td height="28">
<p align="left">
<input type="submit" name="process" value="Process">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
,我将此表单提交到 proccessUpload.jsp 在 processUpload.jsp 中,我上传文件,上传文件完成后,我想重定向到包含表单的源页面。
问题:我想让这个 processUpload.jsp 通用,这意味着我将在其他 Web 应用程序中重用它。无论哪个页面向该 jsp 页面发出请求,我都会获得源页面的确切名称。
任何建议或解决方案。提前致谢。
内森·潘
I have a form
<form name=frmMain method="POST" action="processUpload.jsp" enctype="multipart/form-data">
<p align="center"><table border="1" align="center" width="90%" cellspacing="0" bordercolordark="white" bordercolorlight="black">
<tr>
<td width="261" height="111">
<table border="0" cellspacing="0px" bordercolor="#B9B9B9" id="AutoNumber1" style="border-collapse: collapse" cellpadding="0px" align="left" width="100%" height="114">
<tr>
<td width="264" height="25" colspan="2" bgcolor="#FCDCA0">
<p align="left"><b><font face="Tahoma" size="2"> </font><font face="Tahoma">Upload you excel file</font></b></p>
</td>
</tr>
<tr>
<td width="15px" height="23">
<p align="right" style="vertical-align: middle"><font face="Verdana" size="2"><b> File: </b></font> </td>
<td width="300px" height="23">
<p align="left"> <input type="file" name="excelfile" size="40" >
</td>
</tr>
<tr>
<td width="15px" height="28">
<p align="center"></td>
<td height="28">
<p align="left">
<input type="submit" name="process" value="Process">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
I submit this form to prcessUpload.jsp
in processUpload.jsp I do upload file, when upload file is finished, I want to redirect to source page which contains the form.
Problem: I want to make this processUpload.jsp generic, means I will reuse it in other web application. whatever page make a request to this jsp page, I will have the exact name of the source page.
any suggestions or solutions. Thanks in advance.
NathanPhan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会在表单中的 URL 中添加一个隐藏参数,告诉
uploadFile.jsp
完成后返回到哪里。您需要向uploadFile
页面添加一个按钮或一些 JavaScript,以便在适当的时间发生这种情况。另一种选择是 JSP 从某个服务器端配置文件中获取重定向位置;例如,通过 servlet 上下文参数。
I would add a hidden argument to the URL in the form that tells the
uploadFile.jsp
where to go back to when it is done. You'd need to add a button or some javascript to theuploadFile
page to make this happen at the appropriate time.Another option would be for the JSP to pick up the redirect location from some a server-side configuration file; e.g. via the servlet context parameters.