如何在 struts 2 中成功从一个 bootstrap 模态重定向到另一个模态
How to redirect from one bootstrap modal to another modal on success in struts 2
我正在使用 Twitter Bootstrap 的模态 Window 功能来显示带有 struts 2 framework
的表单。我可以在提交表单时重定向到另一个模型吗? struts.xml
文件中如何配置?
如果我对你的理解正确的话,你想做的是提交一个模态内的表单,然后你想在另一个模态中显示提交的表单结果。
如果这是你想要做的,你根本不需要另一个重定向。
您可以使用 jQuery AJAX post 将表单值添加到您的操作之一,而不是提交表单,并且可以将响应填写到另一个模式框中并显示模态框。
<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">×</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">×</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 -->
我正在使用 Twitter Bootstrap 的模态 Window 功能来显示带有 struts 2 framework
的表单。我可以在提交表单时重定向到另一个模型吗? struts.xml
文件中如何配置?
如果我对你的理解正确的话,你想做的是提交一个模态内的表单,然后你想在另一个模态中显示提交的表单结果。
如果这是你想要做的,你根本不需要另一个重定向。
您可以使用 jQuery AJAX post 将表单值添加到您的操作之一,而不是提交表单,并且可以将响应填写到另一个模式框中并显示模态框。
<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">×</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">×</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 -->