How about, my situation is as follows. I have the html in which I send my Angularjs, however when calling the java Controller from the factory with $ http, it marks me "not found" in the path of the url, in the conttoller is the @RequestMapping, but I can not execute the controller. All this I have in NetBeans 8.2 with spring mvc
- HTML code
<div data-ng-app="myApp">
<div data-ng-controller="MyController">
<button data-ng-click="getDataFromServer()">
Test Angularjs
</button>
</div>
</div>
- AngularJS
var app = angular
.module('myApp', ['ngRoute', 'ngResource'])
.controller('MyController', function ($scope, $service, $http, $resource) {
$scope.getDataFromServer = function () {
$service.JS_STST_GetData();
}
}) // end controller
.factory(
'$service',
function ($http) {
return {
JS_STST_GetData: function () {
$http({
method: 'POST',
url: '/TestMaping',
headers: {
'Content-Type': 'application/json'
}
}).then(_success, _error);
},
- Java Controller Code
@Controller
public class VerController {
@RequestMapping(value="/TestMaping", method = RequestMethod.POST)
public String TEST(Model model){
return "Test";
}
@RequestMapping(method = RequestMethod.GET)
public String otroMetodo(Model model){
return "index";
}
}