如何在Struts 2中成功从一个引导程序模式重定向到另一种模式 [英] How to redirect from one bootstrap modal to another modal on success in struts 2

查看:58
本文介绍了如何在Struts 2中成功从一个引导程序模式重定向到另一种模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Twitter Bootstrap的模态窗口"功能显示带有struts 2 framework的表单.提交表单时可以重定向到另一个模型.如何在struts.xml文件中进行配置?

I am using Twitter Bootstrap's Modal Window feature to display a form with struts 2 framework. Can I redirect to another Model when I submit the form. How to do the configuration in struts.xml file?

推荐答案

如果我对您的理解是正确的,那么您要提交的是模态内的表单,然后您要在另一个模态中显示提交的表单结果

If I understood you correctly what you are trying to do is you submit a form which is inside a modal and then you want show the submitted form result in another modal.

如果这是您要执行的操作,则根本不需要其他重定向.

If this is what you want to do you don't need another redirection at all.

您可以做的是代替提交表单,而可以使用jQuery AJAX将表单值发布到您的一个操作中,然后将响应填充到另一个模式框并显示模式框.

What you can do is instead of submitting form you can post the form values to one of your action using jQuery AJAX and the response can be filled into another modal box and the show the modal box.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>


<a type="button" class="btn btn-primary btn-md" data-toggle="modal" data-target="#gridSystemModal"> Launch demo modal </a>

<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="gridSystemModal">
  <div class="modal-dialog" role="document" style="width : 60%; height : 200px;">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title" id="gridSystemModalLabel">Modal 1</h4>
      </div>
      <div class="modal-body">
        <form>
          <div class="form-group">
            <label for="email">Field 1:</label>
            <input type="email" class="form-control" id="email">
          </div>
          <div class="form-group">
            <label for="pwd">Field 2:</label>
            <input type="password" class="form-control" id="pwd">
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal" data-toggle="modal" data-target="#gridSystemModal2">Next</button>
      </div>
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>
<!-- /.modal -->



<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="gridSystemModal2">
  <div class="modal-dialog" role="document" style="width : 60%">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title" id="gridSystemModalLabel">Modal 2</h4>
      </div>
      <div class="modal-body">
        <form>
          <div class="form-group">
            Response of the form submission
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal" data-toggle="modal" data-target="#gridSystemModal">Previous</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal">Save</button>
      </div>
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

这篇关于如何在Struts 2中成功从一个引导程序模式重定向到另一种模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆