java - Spring Controller redirect to another page -
hey got following problem. content of jspx file:
function postsmth() { $.ajax({ type: "post", url: document.getelementbyid("urltxt").value, data: parameters, }); } <input type="hidden" value="${pagecontext.request.contextpath}/foo/foo2/foodat" name="urltxt" id="urltxt"/> <div class="foodat"><a href="javascript:postsmth();"><spring:message code="foo_foo2_foodat_text" text="foodat"/></a></div> so if push submit button, postsmth function called , ajax object paste controller this:
@controller @requestmapping(value="/foo") public class foocontroller { .............. @requestmapping(value="/foo2", method=requestmethod.post) public string homepost(httpservletrequest request) { ........ } @requestmapping(value="/foo2", method=requestmethod.get) public string homeget(httpservletrequest request) { ........ } @requestmapping(value="/foo2/foodat", method=requestmethod.post) public string dothat(httpservletrequest request) { // check authorization map foomap = request.getparametermap(); // in database, depending on parammap return "redirect:/foo/foo1"; } } everything working fine regarding database, problem is, redirect @ end doesn't work. stays @ page foo2.
i'm new spring, maybe little mistake somewhere. cant make out myself.
would nice if have hint. thanks
you making asynchronous form submission using jquery ajax call. so, after request completed need change document location using javascript. e.g., this:
$.ajax({ type: "post", url: document.getelementbyid("urltxt").value, data: parameters, complete: function() { window.location.replace(...); } });
Comments
Post a Comment