head.txt源码:
<table align="center" border="0" width="790" height="12" bgcolor="cyan" cellpadding="0">
<tr>
<td width="100%">
<a href="<%=response.encodeURL("showMenber.jsp")%>">浏览会员</a>|
<a href="<%=response.encodeURL("register.jsp")%>">会员注册</a>|
<a href="<%=response.encodeURL("login.jsp")%>">会员登录</a>|
<a href="<%=response.encodeURL("find.jsp")%>">查找会员</a>|
<a href="<%=response.encodeURL("message.jsp")%>">留言板</a>|
<a href="<%=response.encodeURL("publicMessage.jsp")%>">查看公共留言</a>|
<a href="<%=response.encodeURL("seretMessage.jsp")%>">查看私人留言</a>|
<a href="<%=response.encodeURL("modifyPassword.jsp")%>">修改密码</a>|
<a href="<%=response.encodeURL("modifyMessage.jsp")%>">修改个人信息</a>|

</td>
</tr></table>
JSP源码
[code=jsp]
<%@ page contenType="text/html language="java" import="java.util.*" charset="GBK" pageEncoding="UTF-8"%><%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
  </head>
  
  <body bgcolor=yellow>
   <%@ include file="head.txt" %>
    <h1>
     <center>欢迎网上结交朋友</center>
    </h1>
  
[/code]
为什么在MYECLIPSE里运行JSP后从head.txt包含进来的文字出现了乱码,怎么解决呢?

解决方案 »

  1.   

    在head.txt里面加上<%@ page contenType="text/html language="java" import="java.util.*" charset="GBK" pageEncoding="UTF-8"%> 
      

  2.   

    试试 --> <%@ page contenType="text/html;charset=GBK" language="java" import="java.util.*"  pageEncoding="GBK"%>  
    如果不行 就用下面的看看<%@ page contenType="text/html;charset=UTF-8" language="java" import="java.util.*"  pageEncoding="UTF-8"%>  
      

  3.   

    charset="GBK" pageEncoding="UTF-8"%> 去掉其中一个同时设置了两次编码了。。整个项目的编码要统一。。不然想不乱码都难何况你还设置了两次不一样的编码
      

  4.   

    request.setCharacterEncoding("utf-8");
    加入这一句
      

  5.   

    <%@ page contenType="text/html language="java" import="java.util.*" charset="GBK" pageEncoding="UTF-8"%> 
    囧写一样了 charset="UTF-8" pageEncoding="UTF-8" 
      

  6.   

    head.txt源码中也要添加编码属性的!
      

  7.   

    可能是设置两次编码的原因,你把那个utf-8去掉试试