问题
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?
回答1:
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.
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">×</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 -->
来源:https://stackoverflow.com/questions/41950603/how-to-redirect-from-one-bootstrap-modal-to-another-modal-on-success-in-struts-2