SSM框架controller中redirect失效
页面发送ajax请求到后台controller 如果在controller中进行页面跳转 只会将跳转页面的源代码发送给success函数,所以只能在success函数中进行跳转,所以 你可以在 success 函数中进行页面跳转 例如
@PostMapping("delete")
@ResponseBody
public String deleteDepartment(Integer departmentId)
{
departmentService.delete(departmentId);
return "/front/departmentList";
}
<script type="text/javascript">
function deleteDepartment(value){
$.post(
"<%=path%>/department/delete",
{departmentId:value},
function x(msg) {
window.location.href = "<%=path%>"+msg;
}
)
}
</script>