javascript - HTTP 404 error in angularjs with spring mvc -
actually want integrate spring angularjs , beginner in angularjs. when use $http post method return post 404 .here code
myapp.js
var myapp = angular.module('myapp', ['ngroute']);
useridcontroller.js
myapp.controller('useridcontroller', [ '$scope', 'useridservice', function($scope, useridservice) { $scope.saveuser = function() { useridservice.saveuser($scope.user).then( function success(response) { console.log("user added"); }, function error(response) { console.log("user not added") }); } } ]);
useridservice.js
myapp.service('useridservice', [ '$http', function($http) { this.saveuser = function saveuser(user) { console.log("enter in service angular") return $http.post('/usersid', { username : user.firstname }) }; }])
i error
request url:http://localhost:8080/usersid request method:post status code:404 remote address:[::1]:8080 referrer policy:no-referrer-when-downgrade
does have idea of i'm doing wrong? seems pretty straight forward implementation working on of tutorials i've seen yet. appreciated. thank you.
controller
public class useridcontroller { private static final logger logger = logmanager.getlogger(useridcontroller.class); requestmapping(value = "/usersid", method = requestmethod.post) responsebody public string storeuser(requestbody studentdetails studentdetails) { logger.debug("enter in post method " + studentdetails.getusername()); string response = "user not exist"; return response; } }
Comments
Post a Comment