81,095
社区成员
发帖
与我相关
我的任务
分享
function saveData() {
var data = ncrForm.getData();
$.ajax({
url : context + "ncrContentController/save.do",
contentType : "application/x-www-form-urlencoded",// 此处重点
type : 'POST',
data : data,
dataType : "json",
success : function(result) {
confirmMessage(result, onCancel);
},
error : function(jqXHR, textStatus, errorThrown) {
mini.alert(jqXHR.responseText);
}
});
}
@RequestMapping("/ncrContentController")
@RestController
public class NcrContentController extends BaseController{
@Autowired
NcrContentService ncrContentService;
@RequestMapping(value = "/save.do", method = RequestMethod.POST)
public BaseResponse save(NcrContent ncrContent) {
BaseResponse baseResponse = new BaseResponse();
try {
//NcrContent ncrContent = JSON.parseObject(ncr, NcrContent.class);
if (StringUtils.isEmpty(ncrContent.getID())) {
ncrContentService.insert(ncrContent);
} else {
ncrContentService.update(ncrContent);
}
return baseResponse;
} catch (Exception e) {
baseResponse.setExceptionMsg(e, "ClassName : " + this.getClass().getName() + " MethodName : "
+ Thread.currentThread().getStackTrace()[1].getMethodName());
return baseResponse;
}
}
}
function saveData() {
var data = ncrForm.getData();
$.ajax({
url : context + "ncrContentController/save.do",
contentType : "application/json",// 此处重点
type : 'POST',
data : JSON.stringify(data),
dataType : "json",
success : function(result) {
confirmMessage(result, onCancel);
},
error : function(jqXHR, textStatus, errorThrown) {
mini.alert(jqXHR.responseText);
}
});
}
@RequestMapping(value = "/save.do", method = RequestMethod.POST)
public BaseResponse save(@RequestBody String ncr) {
BaseResponse baseResponse = new BaseResponse();
try {
NcrContent ncrContent = JSON.parseObject(ncr, NcrContent.class);
if (StringUtils.isEmpty(ncrContent.getID())) {
ncrContentService.insert(ncrContent);
} else {
ncrContentService.update(ncrContent);
}
return baseResponse;
} catch (Exception e) {
baseResponse.setExceptionMsg(e, "ClassName : " + this.getClass().getName() + " MethodName : "
+ Thread.currentThread().getStackTrace()[1].getMethodName());
return baseResponse;
}
}