问题
I wrote the mentioned code
<link rel="Shortcut icon" href="img/favicon.ico"/>
in head section of JSP page and it is able to display the image along with the title name of the page but what I want is it should be reflected on all my pages of project. So what should be done ?
Note: Made a favicn.ico
and environment is java Struts2
回答1:
Create a main page called for example baseLayout.jsp
, which has a section for header, body, footer, toolbar, etc.
Each section you should include using Struts include
tag or similar. In this page you have a head
where you can put your link
tag. As well as this page will be returned by every action, with exception to those actions that return redirect like results, you will have a link on every page.
This is the same concept that used in Tiles framework, where you can define a layout in the tiles config file and use tiles
result type to return by the actions.
Another approach is to create a JSP file with only the link and include it on every page, but it's less productive as above solution.
If you are not familiar with Tiles framework you can read this answer to get started.
来源:https://stackoverflow.com/questions/32357418/how-to-add-image-along-with-title-name-for-all-pages-in-that-project-in-one-code