本來Controller接到普通請求,return “somePage”,這樣就跳轉了。
前台用$.post()提交了數據(不需要回調),我了個大草,return那里就不給跳轉了
這樣怎么解決?
ajax是無法再controller里面return 跳轉的,可以返回后再 ajax的success里面進行 window.location.href
Ajax是異步請求 只會接收最后返回的數據,不會執行頁面跳轉請求改變url地址,要跳轉的話,可以使用window.location.href
$.post()是簡寫的ajax函數
$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType
});
聲明是:
jQuery.post( url [, data ] [, success ] [, dataType ] )
可以在回調函數中處理,或者 .done中處理:
var jqxhr = $.post( "example.php", function() {
alert( "success" );
})
.done(function() {
alert( "second success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "finished" );
});
Null ModelAndView returned to DispatcherServlet with name 'webmvc': assuming HandlerAdapter completed request handling
