我希望使用以下技术开发Web应用程序:Maven、Java、Hibernate、Spring(核心、mvc、security、data)、Bootstrap 3和AngularJs。我想知道两种方法中哪一种是最好的。我的问题是如何组织Web部分。在我的应用程序中有许多HTML页面(homepage.html、login.html、usermanagement.html、profil.hml、project.html):
1.我想使用一个真正的单页应用程序,在一个主文件中使用ng-view标记,并使用routeProvider切换到partials。例如,我可以编写以下代码
1.我想使用一个真正的单页应用程序,在一个主文件中使用ng-view标记,并使用routeProvider切换到partials。例如,我可以编写以下代码
myApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'partials/homepage.html',
controller: 'HomeCtrl'
}).
when('/login/', {
templateUrl: 'partials/login.html',
controller: 'LoginCtrl'
}).
otherwise({
redirectTo: '/'
});
}]);
The second option i have is to make multiple single page application. I this case, each page will be rendered using spring mvc. In each page i will have a angularjs controller. For instance, the following Spring MVC controller renders the home page.
@Controller @RequestMapping( "/" ) public class HomePageController{
@RequestMapping( method = RequestMethod.GET ) public String index() { return "homepage"; }
}
对于主页,我的配置将如下所示:
myhomePageApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'nothing to display',
controller: 'HomeCtrl'
}).
when('/contact/', {
// display contact info in a div on home page
templateUrl: 'partials/contact.html',
controller: 'LoginCtrl'
}).
otherwise({
redirectTo: '/'
});
}]);
因此,它的页面将是一个单页应用程序。
感谢您的阅读和建议。