问题
I have been working on a website which is basically a learning portal and user will have certain lessons inside certain category. My requirement is to build breadcrumbs on the pages. I don't want to hard code at every page.
So could anybody suggest what are the approaches I can use to build breadcrumbs dynamically?
I am using Spring-mvc.
回答1:
Usually, if you're talking dynamic breadcrumbs, they are generated by the server-side technology, rather than purely client-side. The server is going to know the exact page structure and what pages are parents of the current pages.
It'd be more unusual and difficult to do entirely client-side, but certainly possible. You might be able to do something like scrape the URL structure to determine parent pages. For example, if they are at /lessons/lesson1/intro
you might split that string, compare each value against some dictionary of "Nice" values, and display "Lessons > Lesson 1 > Intro"
来源:https://stackoverflow.com/questions/15792114/approaches-to-build-breadcrumbs