博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
struts1-mapping.getInputForward()与mapping.getInput
阅读量:7228 次
发布时间:2019-06-29

本文共 1624 字,大约阅读时间需要 5 分钟。

转自: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方法时出错:\n");
   ex.printStackTrace();
  }
  return forward;
}
转载自:http://www.tiansky.net:8892/DBbbs/viewthread.jsp?tid=236&extra=page%3D1

转载于:https://www.cnblogs.com/sharpest/p/5821597.html

你可能感兴趣的文章
eclipse实现JavaWeb项目 增量打包
查看>>
面试题系列一之 程序生命周期
查看>>
设计模式——观察者模式:气象监测应用
查看>>
NSUserDefaults简介及如何使用 NSUserDefaults 存储自定义对象
查看>>
IntelliJ IDEA搭建SpringBoot
查看>>
深入浅出iOS事件机制
查看>>
hadoop理解
查看>>
Oracle——18用户、角色和权限信息的视图总结
查看>>
WordPress 中的 Debug 模式(调试模式)
查看>>
node下使用express框架,ejs模板引擎
查看>>
搜索:文本的匹配算法
查看>>
Fedora 17 LibreOffice 办公套件的安装与汉化
查看>>
scrollview不充满屏幕的原因
查看>>
PHP单例模式
查看>>
解密敏捷自动化测试
查看>>
DelphiMVC拦截器介绍
查看>>
Spring Cloud构建微服务架构:分布式配置中心【Dalston版】
查看>>
iOS 11正式版终于来了!强力助攻小程序
查看>>
开放平台API接口调用频率控制系统设计浅谈
查看>>
Lucene4.3进阶开发之潜龙勿用( 七)
查看>>