I'm trying to post a value and a string[] to Spring MVC. I either get:
HTTP Status 400 - Required String[] parameter 'testCaseNames' is not present
If I turn it to a list:
HTTP Status 400 - Required List parameter 'testCaseNames' is not present
What type should I put then??
var flowName = $('#flowName').val();
var testCaseNames = [];
$('.icons-right .action-icon:first-of-type').each(function() {
testCaseNames.push($(this).attr('name'))
});
console.log(testCaseNames);
$.ajax({
type: 'post',
url: '/create-flow/save',
data: {
flowName: flowName,
testCaseNames: testCaseNames
},
success: (function (result) {
})
});
@RequestMapping(value = "/create-flow/save" , method = RequestMethod.POST)
public @ResponseBody String saveFlow(HttpSession session, @RequestParam("flowName") String flowName, @RequestParam("testCaseNames") String[] testCaseNames)
{
String user = session.getAttribute("loggedUser").toString();
return TestFlow.addFlow(flowName,testCaseNames,user);
}
Output in console:
["sdad", "xzxc"]