Я использую весенний спокойный веб-сервис вместе с угловым JS. Я пытаюсь подключиться к моему внутреннему коду, но не могу этого сделать. Я не могу понять, где именно я ошибаюсь.Получение org.springframework.web.servlet.PageNotFound.noHandlerУдаленная ошибка при использовании Spring Restful Web Service
Вот мой угловой код:
app.constant('REST_URI', 'http://localhost:8181/rest/');
app.factory('FeedbackService',['$http', 'REST_URI', function ($http, REST_URI) {
const addFeedbackAPI = REST_URI + 'feedback/addFeedback';
var addFeedback = function(feedbackData){
return $http.post(addFeedbackAPI, feedbackData);
};
return {
addFeedback : addFeedback
};
}]);
app.controller('feedbackController', ['$scope', 'FeedbackService', function ($scope, FeedbackService) {
$scope.feedbackData = {};
$scope.addFeedback = function() {
$scope.feedbackData.registerDate = new Date();
FeedbackService.addFeedback($scope.feedbackData).then(
function (successResponse) {
$scope.feedbackResponse = successResponse;
},
function (errorResponse) {
$scope.feedbackResponse = errorResponse;
}
);
};
}]);
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/rootApplicationContext.xml</param-value>
</context-param>
<listener>
<listener-class> org.springframework.web.context.ContextLoaderListener </listener-class>
</listener>
<servlet>
<servlet-name>springrest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/webApplicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springrest</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
Контроллер
@RestController(value = "/rest/feedback/")
public class FeedbackController {
@Autowired
private FeedbackService feedbackService;
@RequestMapping(value = "addFeedback", method = RequestMethod.POST)
public long addFeedback(@RequestBody Feedback feedback) {
return feedbackService.addFeedback(feedback);
}
}
Но я получаю 404 ошибки в журналах:
консоль:
http://localhost:8181/rest/feedback/addFeedback 404()
сервер: 01-Feb-2017 10: 05: 49,339 ПРЕДУПРЕЖДЕНИЕ [HTTP-NiO-8181-Exec-9] org.springframework.web.servlet.PageNotFound.noHandlerFound Нет отображения найдено для запроса HTTP с URI [/ отдых/обратная связь/addFeedback] в DispatcherServlet с именем '' springrest
дайте мне знать, если это также не работает –
Извините, он все еще не работает :( –