最近刚刚在做个系统,SSH,大家帮忙看下!
Action:
?
package action;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.MappingDispatchAction;
import service.UserService;
import entity.User;
import forms.FindForm;
import forms.UserForm;
public class UserAction extends MappingDispatchAction {
?private UserService us;
?public ActionForward addUser(ActionMapping mapping, ActionForm form,
???HttpServletRequest request, HttpServletResponse response) {
??UserForm userForm = (UserForm) form;
??User user=new User();
??user.setLogin_name(userForm.getLogin_name());
??user.setLogin_password(userForm.getLogin_password());
??user.setName(userForm.getName());
??user.setGender(userForm.getGender());
??user.setPayment_style(userForm.getPayment_style());
??user.setStatus(userForm.getStatus());
??user.setEmail(userForm.getEmail());
??
??user.setNationality(userForm.getNationality());
??user.setCareer(userForm.getCareer());
??user.setPhone(userForm.getPhone());
??user.setCompany(userForm.getCompany());
??user.setAddress(userForm.getAddress());
??user.setPost_code(userForm.getPost_code());
??user.setEnroll_date(new Date());
??
??us.addUser(user);
??
??HttpSession session=request.getSession();
??session.setAttribute("users", us.list());
??return mapping.findForward("list");
?}
?
?public ActionForward show(ActionMapping mapping, ActionForm form,
???HttpServletRequest request, HttpServletResponse response) {
??HttpSession session=request.getSession();
??session.setAttribute("lists",us.list());
??return mapping.findForward("show");
?}
?public ActionForward findByLogin_Name(ActionMapping mapping, ActionForm form,
???HttpServletRequest request, HttpServletResponse response) {
??FindForm findForm=(FindForm) form;
??request.setAttribute("finds", us.findByLogin_Name(findForm.getFindByLong_name()));
??return mapping.findForward("find");
?}
?public void setUs(UserService us) {
??this.us = us;
?}
}
list.jsp页面中主要功能是用来显示全部的用户,同时有个根据帐户名字来查询的Text和一个查询按扭,我现在要把查询出来的结果也放在list.jsp中:
????? 显示全部用户:
?<logic:iterate id="user" name="lists">
??????? <tr align="center" >
????????? <td height="10"> 正常</td>
????????? <td> <bean:write name="user" property="login_name"/></td>
????????? <td><bean:write name="user" property="name"/></td>
????????? <td><bean:write name="user" property="phone"/></td>
????????? <td><bean:write name="user" property="email"/></td>
????????? <td><bean:write name="user" property="enroll_date"/></td>
????????
?????????
????????? <td><a href="usermes.htm">修改</a><br>
??????????? <a href="listUser2.htm">暂停</a><br>
??????????? <a href="listUser3.htm"> 删除</a><br>
??????? </tr>
??????? </logic:iterate>
那么显示查询结果的代码应该怎么写?如果也用上面</logic:iterate>来迭带的话,就会出现另一个结果找不到的错误!大家帮帮忙!
1 楼 jsun 2008-09-23 把findByLogin_Name这个方法里的代码改下