好贷网好贷款

Struts logic标签及增删改查

发布时间:2016-12-4 5:57:44 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"Struts logic标签及增删改查",主要涉及到Struts logic标签及增删改查方面的内容,对于Struts logic标签及增删改查感兴趣的同学可以参考一下。

-------------------------------------------------老师写的 Acion--------------------------------   public ActionForward execute(ActionMapping mapping, ActionForm form,   HttpServletRequest request, HttpServletResponse response)   throws Exception {  String type = request.getParameter("type");  ActionForward actionForward = null;  if ("insert".equals(type)) {   actionForward = insert(mapping, form, request, response);  } else if ("delete".equals(type)) {   actionForward = delete(mapping, form, request, response);  }else if ("queryAll".equals(type)) {   actionForward = queryAll(mapping, form, request, response);  }    return actionForward;  }   -------------------------------  public ActionForward insert(ActionMapping mapping, ActionForm form,   HttpServletRequest request, HttpServletResponse response)   throws Exception {   // 获取表单中的值 插入到数据库中  UserForm userForm = (UserForm) form;  UserModel userModel = new UserModel();  userModel.insertUser(userForm);  return mapping.findForward("query"); }  public ActionForward delete(ActionMapping mapping, ActionForm form,   HttpServletRequest request, HttpServletResponse response)   throws Exception {   UserModel userModel = new UserModel();  int id = Integer.parseInt(request.getParameter("id"));  userModel.deleteUser(id);  return mapping.findForward("query"); } public ActionForward queryAll(ActionMapping mapping, ActionForm form,   HttpServletRequest request, HttpServletResponse response)   throws Exception {   UserModel userModel = new UserModel();  List list=userModel.queryAll();  request.setAttribute("LIST",list);    return mapping.findForward("list"); }     ------------------------------------------------------------------------------------- Action里写的   UserModel userModel = new UserModel();  List list=userModel.queryAll();  request.setAttribute("LIST",list); -------------------------------------------Select.jsp----------------------------------------------------------------- <logic:iterator id="U" name="list">  name就是request.getAtribute的名字 直接使用就不用 <bean:write name="U" property="id"> <bean:write name="U" property="username"> <bean:write name="U" property="password"> </logic:iterator> -------------------- <beanLwrite  name="" property=""> name 就是 要打印的对象或是得到的setAtribute("s",s)中的"s" 而property是对象中的属性 ------------------------------------------------------------------------------------- Ps:今天老师讲的有点乱..  查询的时候需要新增加个 Aciton <action path="/userQueryAll" type="net.dbet.struts.action.UserAction"> 而 删除的时候又 增加个 Action <action path="/userDelete" type="net.dbet.struts.action.UserAction"> 但是  我问 老师说 可以 把 删除的 和 查询的放到一起....  如果有验证 就会报错..  真是愁人  不知道有没有什么办法 可以 把 validate  固定再 想用的地方 .... 无语 Struts03.rar (1.6 MB) 下载次数: 4

上一篇:sql中 in 、not in 、exists、not exists 用法和差别http://blog.csdn.net/lihan6415151528/article/details/4466914
下一篇:Logic标签

相关文章

相关评论