zoukankan      html  css  js  c++  java
  • struts1-mapping.getInputForward()与mapping.getInput

    转自:https://www.cnblogs.com/azai/archive/2010/06/05/1752416.html

    奇怪为什么登陆失败的时候 没有错误提示.这个问题困扰了N久

    仔细看了下,发现在处理登陆失败情况跳转的页面 原代码用的是mapping.getInputForward();
    断点跟踪了一下 这句运行好以后
    mapping.getInputForward();是个什么东西?!百度了下原来和这个是
    获取action当中input中的值对应的地址

    <action  path="/test"   
                  type="org.apache.struts.webapp.example.TestAction"   
                  name="testForm"   
                  scope="request"   
                 input="testInput">   
    <forward   name="testInput"                   path="/testInput.jsp"/>   
    </action>  
    getInputForward();获取的就是action中input里的testinput,通过testinput又找到forward里这个别名对应的path/testInput.jsp
    mapping.getInput()获取的是action中input里的testinput字符串
    到这里一切就明了了.

    为什么用mapping.getInputForward();了以后就没有错误提示信息呢 因为struts里没有input的配置
    配置..运行..OK

    loginAction代码
    public ActionForward login(ActionMapping mapping, ActionForm form,
       HttpServletRequest request, HttpServletResponse response) {
      MemLoginForm memLoginForm = (MemLoginForm) form;
      MemDAO service = new MemDAOImpl();
      ActionForward forward = null;
      ActionMessages msgs = new ActionMessages();
      try{
       Member mem = service.memLogin(memLoginForm.getLoginName(), memLoginForm.getLoginPwd());
       if (mem!=null){
        request.getSession().setAttribute("member", mem);
        forward = new ActionForward("/mer.do?method=browseIndexMer");
       }else{
        //等价语句
        //forward = new ActionForward("/mer.do?method=browseIndexMer");
        forward = mapping.getInputForward();
        msgs.add("loginError",new ActionMessage(Constants.ADMIN_LOGINERROR_KEY));
        saveErrors(request, msgs);
       }
      }catch(Exception ex){
       logger.info("在执行LoginAction类中的login方法时出错: ");
       ex.printStackTrace();
      }
      return forward;
    }
    转载自:http://www.tiansky.net:8892/DBbbs/viewthread.jsp?tid=236&extra=page%3D1

  • 相关阅读:
    频率和相位有什么关系
    DMA缓冲区乒乓操作的处理
    深入了解DSP与ARM的区别与联系
    python 里 np.array 的shape (2,)与(2,1)的分别是什么意思,区别是什么?(2020年修订)
    手写promise
    axios源码学习记录
    redux 之isPlainObject
    redux教程之源码解析3applyMiddleware(分析在注释中)
    redux教程之源码解析2 combineReducers(分析在注释中)
    redux教程之源码解析createStore
  • 原文地址:https://www.cnblogs.com/sharpest/p/5821597.html
Copyright © 2011-2022 走看看