【发布时间】:2016-05-09 12:49:02
【问题描述】:
我收到解析错误
语法错误:标记“{”是表达式 [user= ${user}] 的第 8 列中的意外标记,从 [{user}] 开始。
home.html
<body ng-controller="mainCtrl" ng-init="user= ${user}">
参考这个例子,我将模型发送到 angularjs Getting data from Spring MVC in Angular JS in the initial view call.
controller.js
angular.module('userSystem', [ 'ngRoute' ]).config(
function($routeProvider, $httpProvider) {
$routeProvider.when('/', {
templateUrl : 'home.html',
controller : 'home'
}).when('/login', {
templateUrl : 'login.html',
controller : 'navigation'
}).otherwise('/');
}).controller('mainCtrl',
function($rootScope, $scope, $http, $location, $route) {
})
});
弹簧控制器
@RequestMapping(value = "/", method = RequestMethod.GET)
public String getIndex(Model model)
{
model.addAttribute("user","user");
return "home";
}
请让我知道这里出了什么问题以及如何解决它。谢谢
【问题讨论】:
-
你能把
mainCtrl的代码也贴出来吗? -
感谢更新。您似乎错误地声明了您的控制器,它应该看起来像这样
.controller('mainCtrl', ["$rootScope", "$scope", "$http", "$location", "$route", function($rootScope, $scope, $http, $location, $route) {}]); -
用户春天回来,我已经添加了代码
-
你能发布你使用的代码吗?
标签: angularjs spring-boot