This is my situation, I have a project in Netbeans 8.2, in the html, here call angularjs, but when need to call java controller from angular we receive a "not found" in chrome debug, in the factory with the $http send the "url", but I dont can to call java controller.
-- This is code html
<div data-ng-app="myApp">
<div data-ng-controller="MyController">
<button data-ng-click="getDataFromServer()">Test Angularjs</button>
</div>
</div>
-- This is the code in angularjs (this is a File.js)
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);
},
-- This is the 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";
}
}