【发布时间】:2016-12-15 20:31:05
【问题描述】:
我有一个 JSP 页面,其中有一个如下所示的超链接:
<p class='posDash1'>
<input type="hidden" name="export" value="export_csv">
<a href="/admin/" name ="export"><img class="csvFile" src="/images/excel_logo.gif"/> Export.csv</a>
</p>
现在,如果我单击此超链接,我需要在 servlet 中调用我的方法之一。所以在 href 中,我提供了我的 servlet 名称。这里一切正常,这意味着每当我单击此 href 时,我现在都可以调用我的 servlet 我不确定如何在 servlet 中识别此调用来自 href 链接单击。
所以我添加了一个输入隐藏值,我认为,我将能够识别出这个调用来自 href 点击链接,但不知何故它不起作用:
public void handleRequest(HttpServletRequest req, HttpServletResponse resp) throws Exception {
Response rr = null;
// but this always come as null
String export = req.getParameter(export);
if(export.equals("export_csv)) {
// do something here
}
// some code
}
并且每次导出变量值都以 null 出现,因此我无法确定此调用来自 href 链接单击。有什么办法可以解决这个问题吗?
【问题讨论】: