如何在Java Struts2中的一个代码中为该项目中的所有页面添加图像以及标题名称 [英] How to add image along with title name for all pages in that project in one code in java struts2

查看:56
本文介绍了如何在Java Struts2中的一个代码中为该项目中的所有页面添加图像以及标题名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了提到的代码

<link rel="Shortcut icon" href="img/favicon.ico"/>

位于JSP页面的头部,它可以显示图像以及页面的标题名称 但是我想要的是它应该反映在项目的所有页面上.那么应该怎么做呢?

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 ?

注意:做了一个favicn.ico并且环境是java Struts2

Note: Made a favicn.ico and environment is java Struts2

推荐答案

创建一个名为baseLayout.jsp的主页,该页面包含页眉,正文,页脚,工具栏等部分.

Create a main page called for example baseLayout.jsp, which has a section for header, body, footer, toolbar, etc.

每个部分都应包括使用Struts include标记或类似标记.在此页面中,您有一个head,您可以在其中放置link标记.该页面以及每个操作都将返回该页面,除了那些返回重定向(如结果)的操作外,您还将在每个页面上都有一个链接.

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.

这与Tiles框架中使用的概念相同,在Tiles框架中,您可以在Tiles配置文件中定义布局,并使用tiles结果类型由操作返回.

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.

另一种方法是创建仅包含链接的JSP文件,并将其包含在每个页面上,但是与上述解决方案相比,它的生产率较低.

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.

如果您不熟悉Tiles框架,则可以阅读 这个答案就可以开始使用.

If you are not familiar with Tiles framework you can read this answer to get started.

我正在考虑使用简单的功能,例如用于导航的侧边栏和带有网站名称的顶部横幅等,并且希望在每个页面中都可以使用.

I'm thinking of using simple features such as a side bar for navigation and banner across the top with the website name etc, and would like this to be carries across every page.

您肯定是需要通过 tiles-2插件或 tiles-3插件

网上有很多关于这些主题的示例教程,例如

there's plenty tutorials with examples on the web on these theme, for example

  • Struts 2 Tiles Integration Tutorial
  • Struts 2 Tutorial Series – How to insert Tiles to your project
  • Struts 2 Tiles Plugin Tutorial with Example in Eclipse
  • Struts 2 Tiles Framework Integration Tutorial Example
  • Struts2 Tiles Example
  • Working With Struts 2 Tiles, Struts 2 Tiles Example

我已经读到要在JSP中执行此操作,我必须使用标记文件(存储在WEB-INF文件夹中),然后在每个JSP页面上链接到这些文件吗?

I have read that to do this in JSP I have to use tag files (stored in the WEB-INF folder) then link to these on each JSP page?

标记有点过时,但是在JSP中,您应该使用 struts标记

Tags is a bit outdated, however in the JSP you should use struts tags

我还看到人们在Photoshop中创建这些横幅和侧边栏等,这是网站开发中通常发生的事情吗?

Also I have seen people creating these banners and sidebars etc in Photoshop, is this what normally goes on in web site development?

是的,横幅,图像是用它设计的.

Yes, that banners, images, designed with it.

总而言之:在使用JSP和Struts 2框架的同时创建外观精美的网页.

To sum it up: Creating a decent looking web page whilst using JSPs and the Struts 2 framework.

这篇关于如何在Java Struts2中的一个代码中为该项目中的所有页面添加图像以及标题名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆