如何從jsp向Springmvc控制器發送多個數據以更改密碼。 我想使用角度js更改密碼。 如何解決這個問題? 請任何人幫助我。
警報消息正確顯示,但無法使用post方法調用控制器。
我的js代碼
myangu.controller('account', function($scope, $http) {
var submitvalue = $scope.detailspassword = function() {
alert($scope.confirmpassword + "" + $scope.newpassword + ""
+ $scope.existedpassword);
};
var submitvalue = function(request) {
};
var error = function(reason) {
alert("failure message: " + JSON.stringify({
reason : reason
}));
$scope.errormessage = "Something Wrong.Cannot Change Your Password";
};
$http.post('/java/updatepassword').then(submitvalue, error);
});
控制器用SpringMVC
@RequestMapping(value = "/updatepassword", method = RequestMethod.POST,produces="application/json")
public @ResponseBody String updatepassword(@RequestBody Users users) throws JSONException,NullPointerException,JsonGenerationException{
System.out.println("Updatedpassword"+users.getPassword());
return uservice.updatepassword(users);
}
Jsp頁面
<div class="divTablebody">
<div ng-controller="account">
<%-- <form:form action="/java/changepassword" method="POST" > --%>
<div>{{errormessage}}</div>
<div class="divTableRow">
<div class="divTableCell">Existed password:</div>
<div class="divTableCell">
<input type="password" placeholder="Existed Password"
id="Existedpw" ng-model="existedpassword">
</div>
</div>
<div class="divTableRow">
<div class="divTableCell">New password:</div>
<div class="divTableCell">
<input type="password" placeholder="New Password" id="newpw"
ng-model="newpassword">
</div>
</div>
<div class="divTableRow">
<div class="divTableCell">Password Confirmation:</div>
<div class="divTableCell">
<input type="password" placeholder="Confirm Password "
id="confirmpw" ng-model="confirmpassword">
</div>
</div>
<div class="divTableRow">
<div class="divTableCell">Save</div>
<div class="divTableCell">
<input type="submit" id="pwsubmit" ng-click="detailspassword()" name="Submit">
</div>
</div>
myangu.controller('account',[ \t \t'$ scope', \t \t '$ HTTP', \t \t函數($範圍,$ HTTP){ \t \t \t \t \t $ scope.detailspassword =函數(){ \t \t \t \t警報($ scope.confirmpassword + 「」+ $ scope.newpassword +「」 \t \t \t \t \t \t + $ scope.existedpassword); \t \t \t \t VAR FORMDATA = { \t \t \t \t \t公共社會行動中心:$ scope.confirmpassword, \t \t \t \t \t newpass:$範圍。新密碼, \t \t \t \t \t oldpass:$ scope.existedpassword \t \t \t \t}; \t \t \t \t \t \t \t \t VAR誤差=函數(性反應){ \t \t \t \t \t \t \t \t \t \t $ scope.errormessage = 「不成功」; \t \t \t \t \t \t \t \t \t \t}; \t \t \t \t $ http.post('/ java/updatepassword')。then(formData,error);}; \t \t}]);不工作@Ritchie –
請檢查您的評論編輯 –
是檢查它,但不工作先生@裏奇 –