- 浏览: 304048 次
- 性别:
- 来自: 深圳
-
文章分类
最新评论
-
大壮哥哥12138:
写的真好
forward和redirect的区别 -
harim:
好详细的文章!
forward和redirect的区别 -
zoneho:
2月份显示的不对!
java获取某年某月的第一天和最后一天 -
苍天百合:
problemListAction.html 都没有写出来 怎 ...
struts2+ibatis+mysql分页实现 -
powerspring:
<<//需要注意的是:月份是从0开始的,比如说如果 ...
java获取某年某月的第一天和最后一天
<mime-mapping>
This tag defines a mapping between a file extension and a MIME type.
The server-default web.xml file in <jakarta>/conf/web.xml contains a list of all the built-in mappings. This tag can be used to extend that list.
There are two required subelements as follows:
- <extension > - file extension (no leading dot), examples: xls, pdf
- <mime-type > - a mime type, eg: application/vnd.ms-excel or text/html
Enabling file downloads via the application/octet-stream MIME type
While most files will download correctly from your site, if you have created a file with an unknown extension, the browser may attempt to display the file using the text/plain MIME type, which will show in the browser as text.
To avoid this behaviour, a mime-mapping can be set for your file to force the browser to download the file. This appropriate MIME type is application/octet-stream. This is a generic type for binary data streams.
Here is an example for an imaginary file type of pqz:
<!-- Send PQZ files as application/octet-stream so the user is asked to download the file -->
<mime-mapping>
<extension>pqz</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
Enabling download of Microsoft Excel spreadsheets
When providing Microsoft Excel spreadsheets for download from your application, some browsers display the file as garbage on the browser unless an appropriate mime-mapping is set.
The desired action, is to prompt for the file to be saved, or to open it in Excel. Newer versions of Internet Explorer may also display the file directly in the browser using the embedded Excel Active-X control.
Adding the following mime-mapping element to web.xml sets the correct mime-type, allowing the browser to interpret the file correctly.
<!-- Set Excel mime-mapping so spreadsheets open properly instead of being sent as an octet/stream -->
<!-- If this is not done, the user may be prompted to save the file, or it may open as garbage text in the browser -->
<mime-mapping>
<extension>xls</extension>
<mime-type>application/vnd.ms-excel</mime-type>
</mime-mapping>
The MIME type used here is vendor-specific (in this case Microsoft), so it has a "vnd." prefix.
Enabling a Favourites Icon
In Internet Explorer, when the URL you are visiting is in your Favourites List, an icon appears next to the URL in the Address bar and next to the website name in the Favourites menu. To see an example, add this page to your Favourites, then refresh. Look at the address bar of the browser, the metawerx logo is displayed. In FireFox the icon is always displayed.
This icon is called the Favourites Icon, and can be customised by
creating a 16x16 or 32x32 Windows Icon file, with an extension of .ico,
and uploading it to the root folder of your website as "favicon.ico".
You can download other site's icons by going to
http://website/favicon.ico. For example: http://wiki.metawerx.net/favicon.ico
.
Note that you may need special graphics software to create or edit
an icon file, as most graphics software does not support this format.
One such piece of software is IrfanView
. However - see below for how to use a PNG file instead.
The Favourites Icon has a file type of image/x-icon. This is not defined by default in the Tomcat configuration.
Add the following mime-mapping element to web.xml sets the correct mime-type, allowing the browser to interpret the file correctly.
<!-- Set Favourites Icon MIME-Type -->
<mime-mapping>
<extension>ico</extension>
<mime-type>image/x-icon</mime-type>
</mime-mapping>
On modern browsers, a newer method for adding a favourites icon has been added. This method now takes preference over the default favicon.ico file. Therefore, for best results on your web pages, include the following line in your HTML as well. For compatibility with older browsers however, we recommend using the favicon.ico method.
<link rel="icon" type="image/ico" href="/favicon.ico"/>
- Using a link in this way also allows different icons for different pages of your site
- You can also use a PNG image by using image/png above instead of image/ico.
- href can point to any valid image location, as long as the image is the correct type (ico if you specified image/ico, png if you specified image/png etc..) and size (16x16 or 32x32)
发表评论
-
简单ThreadLocal 实例
2012-09-26 15:50 1364测试类: public class TestLocal { ... -
PMD规则之Braces Rules
2012-09-18 15:57 976IfStmtsMustUseBraces: Avoid ... -
PMD规则之Basic Rules
2012-09-18 15:57 3163更多请参考:http://blog.csdn.net/jack ... -
准备做个网站练练手
2012-04-12 23:52 1076准备做个网站练练手,希望能够通过这个网站学习到最新的技术,希望 ... -
el表达式在jsp中不起作用 ${}
2012-02-21 10:23 2287el表达式在jsp中不起作用 ${xxx } 现在tag ... -
sitemesh装饰后的html中文乱码解决方法
2011-10-19 17:45 1108应用了sitemesh装饰模板后,所有html页面,只有有中文 ... -
配置session超时
2011-10-19 08:39 1430在网上收集了一些信息,自己再验证下看看 1.在web.xml ... -
yahoo treeview取得节点内容
2011-10-10 09:45 952正在使用yahoo treeview生成部门tree,如何把t ... -
Java+EE技术面试题
2011-08-20 14:48 1008Java+EE技术面试题,内容比较全面,值得看看,巩固下基础知 ... -
yui+dwr实现动态tree
2011-04-28 13:59 1210YUI脚本 <script><!-- Y ... -
java子父类内部程序的执行顺序
2011-04-02 15:18 28441.父类的静态方法和静态块 2.子类的静态方法和静态块 3 ... -
Tab选项卡切换效果JavaScript汇总
2011-03-31 14:32 2631非原创来源网络:原文地址:http://paranimage. ... -
JAVA中保留N位小数的方法,例子
2011-03-15 17:10 1020import java.text.DecimalForm ... -
设计模式之Facade(外观 总管 Manager)
2011-03-11 10:15 894Facade模式的定义 : 为子系统中的一组 ... -
设计模式之Singleton(单态)
2011-03-11 10:12 793单态定义 : Singleton模式主要作用是 ... -
设计模式之Builder
2011-03-11 10:10 738Builder模式定义 : ... -
java获取某年某月的第一天和最后一天
2011-03-08 13:24 14762//需要注意的是:月份是从0开始的,比如说如果输入5的话, ... -
session与cookie的区别
2011-03-03 08:38 6136我所知道的有以下区别: 1、ses ... -
forward和redirect的区别
2011-03-03 08:35 699451.从地址栏显示来 ... -
ConcurrentMap和HashMap的区别
2011-03-02 16:02 16747类 HASHSET<E> 所有 ...
相关推荐
### 在web.xml中引入其他XML配置文件的步骤 在Java Web开发中,`web.xml`作为Web应用程序的核心配置文件,负责定义应用级别的配置信息。为了提高代码的可维护性和复用性,有时需要将一部分配置内容提取到独立的XML...
Web.xml 配置详解 Web.xml 是一个部署描述符文件,用于描述 Web 应用程序的配置信息。该文件是基于 XML 语法的,所有的元素都是大小写敏感的。下面是 web.xml 配置文件的详细解释: 定义头和根元素 在 web.xml ...
### 在web.xml中配置action或.do的理解与实践 #### 一、引言 在Web开发领域,特别是基于Java的Web应用程序开发中,`web.xml`文件扮演着至关重要的角色。它不仅定义了Web应用的基本配置,还管理着诸如Servlet、过滤...
在构建基于Spring MVC的Web应用程序时,`web.xml`配置文件扮演着至关重要的角色。它定义了应用程序的行为,包括启动时的初始化、请求处理以及中间件的设置。下面我们将详细探讨`web.xml`中涉及Spring MVC的主要配置...
由于经常使用Maven创建web工程所以需要使用web.xml默认模板
在Tomcat的`conf`目录下,有两个主要的XML配置文件:`server.xml`和`web.xml`。`server.xml`是Tomcat的主要配置文件,而`web.xml`则定义了应用程序的行为。 在`server.xml`中,我们需要配置`<Connector>`元素来启用...
Web.xml是Servlet容器(如Tomcat)的部署描述符,用于配置Web应用程序的各种设置,包括日志配置。本文将详细讲解如何将Log4j整合到Web应用并通过web.xml进行配置,以实现日志信息的输出和管理。 1. **Log4j介绍** ...
Web.xml 中的 listener、filter、servlet 加载顺序及其详解 在 Web 应用程序中,web.xml 文件扮演着非常重要的角色,它定义了 Web 应用的结构和配置。其中,listener、filter、servlet 是三个非常重要的概念,它们...
javaweb项目中web.xml的作用 web.xml是javaweb项目中一个非常重要的配置文件,它是每一个javaWeb工程都必需的配置文件。web.xml文件的主要作用是用于初始化工程配置信息,例如welcome页面、filter、listener、...
首先,"jboss-web.xml"是JBoss特定的Web应用程序部署描述符,它是Tomcat中的web.xml在JBoss环境中的扩展。这个文件主要负责定义应用的Servlet、过滤器、监听器以及与EJB交互的JNDI(Java Naming and Directory ...
在Java Web开发中,`struts.xml`, `applicationContext.xml` 和 `web.xml` 是三个至关重要的配置文件,它们各自负责不同的职责,并协同工作来构建一个完整的应用框架。以下是关于这三个配置文件的详细说明。 首先,...
在Java Web应用中,`web.xml`文件是部署描述符(Deployment Descriptor),它定义了应用程序的行为、组件配置以及服务器如何处理请求和响应等关键信息。`error-page`标签是`web.xml`中的一个重要元素,用于处理HTTP...
web.xml是Java Servlet规范定义的一个部署描述文件,用于配置Java Web应用程序。它遵循XML的规则,必须有一个唯一的根节点,大小写敏感,并且标签需要严格配对。在大型Web工程中,web.xml文件非常重要,因为它提供了...
web.xml 各属性作用描述 Web.xml 常用元素 <web‐app> ‐name>‐name>定义了WEB 应用的名字 <description></description> 声明WEB 应用的描述信息
`web.xml`是Java Web应用程序的核心配置文件,用于定义应用服务器如何初始化和管理Web应用程序。它遵循Java Servlet规范中的标准,为开发者提供了一种结构化的方式来配置Servlet、过滤器、监听器和其他组件。理解`...
servlet的写登陆管理系统用到的web.xml
WEB-INF中的web.xml配置详解 本文将详细介绍WEB-INF中的web.xml文件中的配置,包括Context配置、Resource配置、resource-ref配置,以及对应的Java类编写。 一、Context配置 在WEB-INF中的web.xml文件中,添加以下...
web.xml 配置详解 web.xml 是一个 XML 文件,用于描述 Servlet/JSP 应用的各个方面的元素,如 servlet 注册、servlet 映射以及监听器注册。下面是 web.xml 文件的详细解释: XML 头 web.xml 文件以 XML 头开始,...
传统的SpringMVC配置往往依赖于XML文件,如web.xml和spring-servlet.xml等,但随着Spring框架的发展,出现了基于代码的配置方式,实现了零XML配置,提高了开发效率。本文将详细介绍如何在不使用web.xml的情况下,...
在本文中,我们将探讨Spring在`web.xml`中的配置与在Struts中的配置差异,以及这两种配置方式背后的基本原理。 首先,Spring的核心是ApplicationContext,它是一个管理Bean的容器,可以看作是应用程序的上下文环境...