我有一个JSP页面,其中有多个搜索选项,即“按应用程序ID搜索”,“按申请人名称搜索”等。我使用struts EventDispatchAction来捕获特定提交按钮生成的事件。这工作正常。下面是struts-config文件的快照:
现在我在分页搜索结果方面遇到问题,因为单击页码时我无法生成事件。它们是超链接。以下是用于生成页码的代码:
<c:forEach items="${pagelist}" var="emp">
<td><a href="#?page=${emp}">${emp}</a></td>
</c:forEach>
我不知道应该用什么代替#来为EventDispatchAction生成事件。捕获提交的ActionClass如下:
public class SearchApplicationAction extends org.apache.struts.actions.EventDispatchAction {
public ActionForward idSubmit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
List applist = null;
SearchApplicationForm searchApp = (SearchApplicationForm) form;
String idText = searchApp.getAppId();
int appId = Integer.parseInt(idText);
UserManager manager = new UserManager();
applist = manager.ViewApplicationById(appId);
sess.setAttribute("applicationList", applist);
return mapping.findForward("idSubmit");
}
public ActionForward nameSubmit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
List applist = null;
SearchApplicationForm searchApp = (SearchApplicationForm) form;
String name = searchApp.getApplicantName();
UserManager manager = new UserManager();
applist = manager.ViewApplicationByName(name);
sess.setAttribute("applicationList", applist);
return mapping.findForward("nameSubmit");
}
}
这方面的任何帮助都会非常有帮助。感谢
答案 0 :(得分:0)
谢谢米格尔。实际上,问题不在于使用链接操作,而是捕获适当的事件。当用户单击任何搜索选项时,将在SearchApplicationAction中处理该事件。但在对搜索结果进行分页后,只要有人点击页码,我就必须生成这些操作。如果我在超链接中对操作进行硬编码,那么它可以工作
<td><a href="searchApplication.do?nameSubmit&page=${emp}">${emp}</a></td>
答案 1 :(得分:-1)
您可以使用struts taglib:<html:link>
来构建与struts操作相关的链接。请参阅:http://struts.apache.org/1.x/struts-taglib/tagreference.html#html:link