我使用Struts 2.2。
我已经迭代了ArrayList
个用户。我有一个每个用户的编辑链接。
单击编辑链接时,我想在数据库中找到该用户并显示其属性。
不幸的是,链接不会将我带到所需的页面,而是将其重定向到同一页面。有什么想法吗?
display.jsp:
<logic:iterate id="customerElement" name="ACTIVE_PROFILES_LIST" property="list">
<tr>
<td>
<bean:write name="customerElement" property="lastName"/>
</td>
<td>
<bean:write name="customerElement" property="firstName"/>
</td>
<td>
<pdk-html:link action="/beforeEditProfile.do?toEdit=${customerElement.login}">Edit</pdk-html:link>
</td>
</tr>
</logic:iterate>
动作类:
public class BeforeBeforeEditProfileAction(){
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws IOException,
ServletException {
// retrieve the parameter
String toModify= request.getParameter("toEdit");
SearchBean search = new SearchBean();
Cetatean cet = search.getSingleCitizen(toModify);
LogManager.info("BeforeEditProfileAction: ENTER");
if(cet!=null){
request.setAttribute("cetatean", cet);
LogManager.info("BeforeEditProfileAction: cetatean not null");
return mapping.findForward("succes");
}
else {
LogManager.info("BeforeEditProfileAction: cetatean null");
return mapping.findForward("failure");
}
}
}
的struts-config.xml
<action path="/beforeEditProfile" type="pm.action.BeforeEditProfileAction" name="user" validate="true" scope="request" input="/htdocs/pages/display.jsp">
<forward name="success" path="/htdocs/pages/editProfile.jsp"/>
<forward name="failure" path="/htdocs/pages/profileEditedFailed.jsp"/>