2
我想發表我的表格數據到我的休息服務使用角js和澤西島。然而,其餘服務收到的bean是空的。以下是我的POST請求的角碼。澤西島的角JS對象後null
(function() {
var dataUrls = {
addSurveyUrl : '/CompanySurveyPortal/Company/Surveys/addSurvey'
}
angular.module('addNewSurvey', []).service('addSurveyDataService',
function($http) {
this.addNewSurvey = function(survey)
{
return $http.post(dataUrls.addSurveyUrl, {"surveyId": survey.surveyId, "title": survey.question, "choice1": survey.firstOption, "choice2": survey.secondOption ,"status": 'Open'});
};
})
.controller('AddNewSurveyController', function($scope, $log, responseDataService, $stateParams, $state, $filter, $rootScope, addSurveyDataService){
this.survey = {};
this.addSurvey = function(){
addSurveyDataService.addNewSurvey(this.survey);
};
function init(){
}
init();
})
})();
表單中的數據已成功填充到$ http.post語句中。然而,每次消耗請求的方法中的bean都是空的。
@POST
@Path("addSurvey")
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_JSON)
public void addNewSurvey(@BeanParam Survey survey,
@Context HttpServletResponse servletResponse) throws IOException,
SQLException {
SurveyDao surveyDao = new SurveyDao();
surveyDao.addSurvey(survey);
}