登录后工作时AngularJS重定向到主页

时间:2016-02-04 09:53:27

标签: angularjs html5 spring-mvc spring-security

我的应用程序是使用spring + angularJS,在从控制器进行身份验证后,我无法重定向到主页。

console.log("id:"+employee.id);     

alert("Trying to redirect to home page");
$location.path("/home/"+employee.id);

当执行此操作时,http://localhost:9393/login#/home/21正在重定向到网址,但我想要http://localhost:9393/home/21(没有/ login#)

2 个答案:

答案 0 :(得分:2)

哈希是因为hashbang模式。你将不得不配置html5模式。本教程解释了如何启用html5mode(漂亮的url) HTML 5 Mode- angularJs

有关详细信息,请查看AngularJS Guide for $location

答案 1 :(得分:1)

这是因为$ location正在使用Hashbang URL,您可以通过启用Html5Mode来更改此位置。 enter image description here

因此请将此包含在模块的.config方法中。

locationProvider.html5Mode(true);

有关详细信息,请查看AngularJS Guide for $location