这是控制器代码
@RequestMapping(value="doLogin")
public ModelAndView doLogin(@ModelAttribute @Valid UserBean userBean,BindingResult result)
{
ModelAndView view = new ModelAndView("login");
if(!result.hasFieldErrors())
{
if(!combatService.authenticateUser(userBean))
{
result.addError(new ObjectError("err", "Invalid Credentials"));
}
else
{
if(retrieveService.getdata(userBean) != null)
{
List<UserBean> username=retrieveService.getdata(userBean);
return new ModelAndView("welcomes", "usernames", username);
}
}
}
return view;
}
这是有角度的js
<body ng-app="myApp" ng-controller="customersCtrl">
<div ng-init="usernames = ${usernames}">
<ul id="myUL">
<li ng-repeat="x in usernames"><a href="#">{{x.username}}</a></li>
</ul>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http({
method: "GET",
url: "http://localhost:8080/maven_project/toLogin.obj"
})
.then(function (response) {$scope.usernames = response.data.usernames;
alert('success');},
function (error) {
alert('failed');
});
});
</script>
</body>
这是错误
angular.js:14800 Error: [$parse:ueoe] http://errors.angularjs.org/1.6.9/$parse/ueoe?p0=usernames%20%3D
at q.consume (angular.js:15365)
at q.primary (angular.js:15240)
at q.unary (angular.js:15224)
"<div class="md-form active-cyan active-cyan-2 mb-3" ng-init="usernames = ">"
(anonymous) @ angular.js:14800
它将值从控制器传递到视图,并执行成功,但未显示任何记录。我尝试了很多。谁能找出错误是什么问题
答案 0 :(得分:0)
我认为您应该删除 TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(context, trackSelector);
playerView.setPlayer(player);
player.prepare(contentMediaSource);
player.setPlayWhenReady(true);
player.seekTo(positionFromFirstActivity);
指令,这是导致错误的原因,我不确定该怎么做。
像现在一样,在http响应处理程序中初始化ng-init
就足够了。
希望这会有所帮助