spring mvc [@ResourceMapping] [1]获取liferay spring MVC portlet中的对象列表????
问题是什么?
var jsonObjCommand =[{
dc: $("#dcCode").val() ,
question_Score : $("#101p").val() ,
question_Desc: $("#101d").val(),
"clinicAnalyzeQuestions.id" : 102,
"clinicAnalyzeQuestions.questions" : 'test',
"mobile" : $('#mobile').val(),
"state" : $('#state').val()
},{
dc: $("#dcCode").val() ,
question_Score : $("#102p").val() ,
question_Desc: $("#103d").val(),
"clinicAnalyzeQuestions.id" :102,
"clinicAnalyzeQuestions.questions" : 'test2',
"mobile" : $('#mobile').val(),
"state" : $('#state').val()
}];
$.ajax({
url : "${insert}",
type : 'POST',
datatype : 'json',
data : JSON.stringify(jsonObjCommand) ,
success : function(data) {
var content = JSON.parse(data);
$.each(content, function(i, state) {
$("#container2").hide();
$("#container").hide();
$("#frm1").hide();
$('#success').show();
$('#userCount4').text(state.success);
});
}
});
// controller
@ModelAttribute(value = "jsonObjCommand")
public List<ClinicAnalyzeAnswers> obtenerJsonObjCommand() {
List<ClinicAnalyzeAnswers> jsonObjCommand = new ArrayList<ClinicAnalyzeAnswers>();
System.out.println(jsonObjCommand.size());
return jsonObjCommand;
}
@ModelAttribute("jsonObj1")
public ClinicPerson clinicPerson() {
ClinicPerson person = new ClinicPerson();
return person;
}
// @Transactional
@ResourceMapping("insert")
public void ajaxTestMethod(
ResourceRequest request,
ResourceResponse response,
@ModelAttribute(value = "jsonObjCommand") List<ClinicAnalyzeAnswers> jsonObjCommand,
@ModelAttribute(value = "jsonObj1") ClinicPerson person)
throws IOException, ParseException {
for (ClinicAnalyzeAnswers clinicAnalyzeAnswers : jsonObjCommand) {
System.out.println(clinicAnalyzeAnswers.getDc()+"aaa");
}
}
spring mvc [@ResourceMapping] [1]获取liferay spring MVC portlet中的对象列表????
在controller null []数组中 帮助我......
答案 0 :(得分:1)
您必须更改您的ajax请求,因为ResourceMapping
方法您不会收到jsonObjCommand
或jsonObj1
$.ajax({
url : "${insert}",
type : 'POST',
datatype : 'json',
data : {"jsonObjCommand" : JSON.stringify(jsonObjCommand)},
success : function(data) {
...
}
});