使用$.post()方法提交时候后台没有跳转到指定的页面,页面内容返回到resulut中了。
前台方法:
function reportToExcel(){
var d=$("#search").serialize();
console.log(d);
$.post("report_createToExcel.action", d, function (result)
{
console.log(result);
});
}
后台xml配置
<action name="report_createToExcel"
class="com.ReportCreateToExcelAction">
<result name="success" type="dispatcher">excel.jsp</result>
</action>
本来应该跳转到excel.jsp,但是没有发生跳转,在console.log(result)中result显示的内容是excel.jsp的内容。
上网查了一下发现,ajax是无法再controller里面return 跳转的,可以采用
var form = document.getElementById('search');
form.submit();
的方式去提交。