有个html文件如下:utf-8编码的
<%@ page language="java" contentType="text/html; charset=gb2312"%>
<html>
<head>
<title> 个人所得税计算器</title>
</head>
<body>
<center>
<form name="form1" method="post" action="SampleServlet4">
<table width="358" height="140" border="0" cellpadding="0" cellspacing="0" bgcolor="#E6E6E6">
<tr align="center">
<td colspan="3"><strong>个人所得税计算器</strong></td>
</tr>
<tr>
<td colspan="2">当月个人总收入:</td>
<td width="177"><input name="sumincom" type="text" id="sumincom"></td>
</tr>
<tr>
<td colspan="2">当地个人所得税起征额:</td>
<td><input name="taxstart" type="text" id="taxstart"></td>
</tr>
<tr align="center">
<td width="161" align="right"> <input type="submit" name="Submit" value="确定">
</td>
<td width="20"></td>
<td align="left"> <input type="reset" name="Submit2" value="重填"></td>
</tr>
</table>
</form>
</center>
</body>
</html>我直接双击用IE打开,可以正常显示
但是我在地址栏里输入http://localhost:8080/MyFirstServlet/Sample3.html却显示全是乱码!!
同样的浏览器,怎么会有不同的效果呢?
谢谢指导!!
<%@ page language="java" contentType="text/html; charset=gb2312"%>
<html>
<head>
<title> 个人所得税计算器</title>
</head>
<body>
<center>
<form name="form1" method="post" action="SampleServlet4">
<table width="358" height="140" border="0" cellpadding="0" cellspacing="0" bgcolor="#E6E6E6">
<tr align="center">
<td colspan="3"><strong>个人所得税计算器</strong></td>
</tr>
<tr>
<td colspan="2">当月个人总收入:</td>
<td width="177"><input name="sumincom" type="text" id="sumincom"></td>
</tr>
<tr>
<td colspan="2">当地个人所得税起征额:</td>
<td><input name="taxstart" type="text" id="taxstart"></td>
</tr>
<tr align="center">
<td width="161" align="right"> <input type="submit" name="Submit" value="确定">
</td>
<td width="20"></td>
<td align="left"> <input type="reset" name="Submit2" value="重填"></td>
</tr>
</table>
</form>
</center>
</body>
</html>我直接双击用IE打开,可以正常显示
但是我在地址栏里输入http://localhost:8080/MyFirstServlet/Sample3.html却显示全是乱码!!
同样的浏览器,怎么会有不同的效果呢?
谢谢指导!!
或者
byte [] t=name.getBytes("ISO-8859-1");
name=new String(t,"GB2312");