I am using AngulaJS as a javascript client side and spring mvc as a rest backend. In AngulaJS i am using ui-router.
Here is config.js file
function config($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/index");
$stateProvider
.state('trains', {
url: "/trains",
templateUrl: "views/pages/trains.html",
data: {
pageTitle: 'Trains'
}
})
Below is html file (left-sliderbar.html
<li ui-sref-active="active">
<a href="javascript:;" ui-sref="trains" title="the trains">Trains </a>
</li>
The problem is when I clicked on "Trains" menu in left left-sliderbar, I cannot get request mapping with the method in Rest Backend of Spring MVC. Below is code from Controller of Spring MVC
@RequestMapping("/trains")
public String getTrainPartialPage(ModelMap modelMap) {
System.out.println("---------Request Mapping: /trains: " + this.getClass());
return "pages/trains";
}
Please help me to fix it out, I'd like to use ui-router than ngRoute, thanks you
and you need to implement the rest calls in your service or in your TrainsController.
I had the same problem in a same context.
I think you shoud try to use
templateUrl: "views/pages/trains"
instead oftemplateUrl: "views/pages/trains.html"
in your$stateProvider
provider.The back-end controller should expose this request mapping:
NB: Using
ModelAndView
as a return object instead ofString
(didn't worked withString
and actually I con't figure why).Angular UI Router will write
/train
in the url and Spring will serve the html file mapped on the/train
route.Hope will help you.