JSP 设置网站icon

新手向的问题,而且我本来也是新手

首先先设置好你要设置成网页logo的icon图片,像素为48X48,改名为favicon.ico,设置好后放到项目的根目录下。

如果用的是myeclipse写项目的话建立出来的jsp页面的话,页面顶端都会有这么一句话的

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>

 

这个变量basePath就是你项目在服务器上的根目录位置,然后只需要在head标签内加上这么一段话

<link rel="icon" href="<%=basePath %>/favicon.ico" type="image/x-icon" /> 即可

posted @ 2012-07-02 11:39  长春任翔  阅读(631)  评论(0编辑  收藏  举报