zoukankan      html  css  js  c++  java
  • ModelAndView返回自己的用法

    我们经常遇到要在一个列表中删除一条记录的情况,删除完毕后,还要返回这个列表,这个时候我们获得列表的方式可能由不同的参数确定的,而我们重新定位到这个页面大部分使用的方式是:return new ModelAndView(new RedirectView("aaa.sf"))这种重新请求的方式,但是,我们可能需要一些额外的参数才能获得我们需要的列表页面。
     现在我们可以以一种新的方式实现这个调用,我们对列表页面需要的参数放到删除请求的form中传送到controller中,这些值都被封装在request中,而我们的ModelAndView这个handler形式的函数主要需要的就是request和reponse这两个参数,也就是说,我们只需要将需要的条件放到request中去就可以了,然后我们可以调用产生你需要的list的那个ModelAndView方法
    例如:
    产生列表的处理函数:public ModelAndView listInformation(HttpServletRequest request,
       HttpServletResponse response) throws ServletException
    删除记录的处理函数:public ModelAndView deleteInformation(HttpServletRequest request,
       HttpServletResponse response) throws ServletException
     
    我们只需要
      String informationId = request.getParameter("informationId");
      this.getInformationDao().delete(informationId);
      return this.listInformation(request,response);
    就可以了返回列表当前页了。
    但是前提是一定要在删除操作提交的时候将那些列表需要的条件提交到request中。
  • 相关阅读:
    css3 动画
    jQuery toast 淡入淡出提示
    JavaScript事件——拖拉事件
    Vue -- element-ui 限制只能输入number
    css 移动端页面,在ios中,margin-bottom 没有生效
    django 快速搭建blog
    python 正则表达式口诀
    [转]python os模块 常用命令
    【转】scapy 构造以太网注入帧
    【转】关于Scapy
  • 原文地址:https://www.cnblogs.com/hqr9313/p/2639909.html
Copyright © 2011-2022 走看看