spring - While form submitting using ajax..getting Post not supported error ...don't know what is the error? -
i using form submission using ajax in spring mvc , thymeleaf. when try submit it shows
post method not supported
i can't figure out mistake in code:
<form class="form-horizontal" action="#" th:action="@{/teacher/teacherprofileupdation}" th:object="${teacherprofiledetailslist}" id="saveteacherform" method="post" > <br /> <div class="row"> <div class="col-lg-14 col-md-12"> <br /> <h5 style="margin-left: 15%;">personal details</h5> <hr /> <div class="form-group"> <label class="col-sm-3 control-label">name</label> <div class="col-md-3 col-sm-4 col-xs-4"> <input placeholder="teacher first name" id="txtteacherfname" th:field="*{firstname}" type="text" class="form-control" /> </div> <div class="col-md-3 col-sm-4 col-xs-4"> <input placeholder="teacher middle name" id="txtteachermname" th:field="*{middlename}" type="text" class="form-control" /> </div> <div class="col-md-3 col-sm-4 col-xs-4"> <input placeholder="teacher last name" id="txtteacherlname" th:field="*{lastname}" type="text" class="form-control" /> </div> </div> </div> <div class="col-lg-14 col-md-12"> <div class="form-actions"> <input type="hidden" id="hdnstudentbyidinschooladmin" value="0" /> <input type="button" class="btn btn-info pull-right" id="btnupdateteacherprofile" value="save" /> </div> </div> </div>
js:
saveteacherprofile :function(){ $("#saveteacherform").ajaxform({ success : function(status) { alert("success"); }, }).submit(); }
controller:
@requestmapping(value = "/updateteacherprofile", method = requestmethod.post) public string updateteacherprofile( teacherprofiledetails teacherprofiledetails){ system.out.println("-----------"+teacherprofiledetails.getfirstname()+"-------------"); system.out.println("-----------"+teacherprofiledetails.getlastname()+"-------------"); system.out.println("-----------"+teacherprofiledetails.getmiddlename()+"-------------"); return "success"; }
you posting form, spring controller not configured accept post requests. try in server-side controller class page:
@requestmapping(..., method = { requestmethod.get, requestmethod.post }, ...) public void mycontrollermethod() {
Comments
Post a Comment