jspからSpringmvcコントローラに複数のデータを送信してパスワードを変更する方法。 角度jを使用してパスワードを変更したいと考えています。 これを解決するには? いずれかお手伝いください。
警告メッセージが正しく表示されていますが、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 cpass:$ 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誤差=関数(responce){ \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 –
はEDITにあなたのコメントを確認してください動作していない –
はい、それをチェックしますが、ブラウザ –