ajax - 对弹簧控制器的 Ajax 调用未返回成功
问题描述
我正在使用带有参数的ajax post到spring mvc控制器,数据绑定良好但没有返回成功。响应将转到另一个页面。
我正在从模态调用 ajax,并且需要将成功消息返回到相同的模态中。
以下是我的ajax调用,
$.post({
url : 'saveEmployee',
data : $('form[name=employeeForm]').serialize(),
processData: false,
success: function (resp) {
alert("hello");
},
failure: function (resp) {
alert("hello1");
}
})
以下是我的控制器代码,
@RequestMapping(value="/saveEmployee", method = RequestMethod.POST)
@ResponseBody
public void Insert(ModelMap model, Principal principal,HttpSession session,@ModelAttribute @Valid Profile profile,
BindingResult result) {
System.out.println("profilec "+profile.getRashi());
}
数据绑定得很好,但是,空页面作为响应返回,成功响应需要返回到相同的模式。
解决方案
推荐阅读
- django - 在 pycharm 上安装 Django 时出错
- amazon-web-services - 无法通过 SSH 连接到 EC2 实例(连接超时)
- spring-boot - Spring Boot 2.2.1 中的外部 application.properties 文件覆盖值
- html - 全高侧边栏和内容区域在较小的设备屏幕上中断
- odoo - 无论装饰器如何,记录集都是空的
- c - 动态确定C中函数参数的类型?
- docker - 在文件 './docker-compose.yml' 中,服务 'image' 必须是映射而不是字符串
- facebook - 历史广告组预算
- java - 有没有办法找出Kafka序列化数据所花费的时间
- c# - Why can't enumerations from different DLLs be accessed through late binding?