How to add image along with title name for all pages in that project in one code in java struts2

被刻印的时光 ゝ 提交于 2019-12-13 07:54:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!