-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
I followed the blog about Spring Security and Angular JS and there is a chapter about "natural" routes. Here a small quote:
the login page is specified as a route in hello.js as "/login" and this translates into "/#/login" in the actual URL (the one you see in the browser window). This is so that the JavaScript in the index.html, loaded via the root path "/", stays active on all routes.
Quote from Using "Natural" Routes
The example works great as long you are using simple routes like:
$routeProvider.when('/', {
templateUrl : 'js/home/home.html',
controller : 'home'
}).when('/login', {
templateUrl : 'js/navigation/login.html',
controller : 'navigation'
}).otherwise('/');` In that you can call in your browser http://..../login and Spring (server side) will forward you to the correct page using the RequestMapping below:
@RequestMapping(value = "/{[path:[^\\.]*}")
public String redirect() {
return "forward:/";
}Unfortunately this only works if you are not using any path variables. But I would like to use routes like:
$routeProvider.when('/', {
templateUrl : 'js/home/home.html',
controller : 'home'
}).when('/users', {
templateUrl: 'js/usermanagement/list.html',
controller: 'userList'
}).when('/users/:id', {
templateUrl: 'js/usermanagement/userDetails.html',
controller: 'userDetails'
}).when('/users/:id/edit', {
templateUrl: 'js/usermanagement/edit.html',
controller: 'userEdit'
}).otherwise('/');If I start my application and the route is used without server side redirect then I am able to navigate to http://..../users/some_id
but if I hit refresh, then I get the a 404.
I tried to fix it by adding another RequestMapping with a different value, but I could not manage it to work.
You can reproduce it by changing three files in the Modular Project, see Changes in Files via Patebin
Then do the following:
- start the spring-boot application and login as usual
- Click on the Show message via URL link
Here you will see that the message content will show the value "link_msg" as shown in the URL. - Hit refresh
Now you will see the Whitelabel Error Page
I do not know how to fix this, but I hope you can.