注册 登录
编程论坛 J2EE论坛

[讨论]jsp文件乱码问题

zhanfuxin 发布于 2006-08-06 13:26, 730 次点击

<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<html>
<jsp:useBean id="checkLogin" class="loginBean.LoginBean"/>
<head>
<title>Using Bean To Longin</title>
<style type="text/css">
<!--
.style4 {color: #8000FF}
.style5 {color: #000000}
-->
</style>
</head>
<body>
<form name="form1" method="post" action="">
<p><span class="style4">»¶Ó­</span><span class="style5"><b><i><%=request.getParameter("username")%></i></span><span class="style4">µÄµ½À´</span>£¡
<a href="denglu.jsp">Í˳ö</a>
</p>
<h2><img src="020.gif" width="32" height="32"><em><font size="3">ÎÒ°®ÊÎÆ·Íø</font></em><a href="www.shipin.com"><font size=3>www.shipin.com</font></a></h2>
<div>
<a href="">ÐÂÎÅ</a>|
<a href="">ÓéÀÖ</a>|
<a href="">ÌåÓý</a>|
<a href="">²Æ¾­</a>|
<a href="">ÉÌÒµ</a>|
<a href="">¿Æ¼¼</a>|
<a href="">Æû³µ</a>|
<a href="">ÊýÂë</a>|<br>
<a href="">Å®ÈË</a>|
<a href="">½¡¿µ</a>|
<a href="">½ÌÓý</a>|
<a href="">ÎÄ»¯</a>|
<a href="">ÂÃÓÎ</a>|
<a href="">¾üÊÂ</a>|
<a href="">²¿Âä</a>|
<a href="">ÂÛ̳</a>|
</div>
<div style="WIDTH:200px; HEIGHT:170px" align=center>
<IMG height=100 src="021.jpg" width=777>
</div>
</form>
<%
checkLogin.init(request,out,response);
checkLogin.execute();
checkLogin.clean();
%>
</body>
</html>
这个文件为什么会乱码吗?昨天运行时还没有这种情况啊?

4 回复
#2
rufeng5212006-08-06 15:39

有些是Dreamweaver自身的问题,不能保存字符数据,虽然你点保存了,再次打开的时候还是乱码的,你上面的jsp文件在显示的时候是不是也出现乱码呢?如果是显示出现乱码问题的话,你可以加几行代码处理就ok了,如果是dreamweaver的问题那就没办法了.

#3
zhanfuxin2006-08-06 15:58

为什么又有问号呢?
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<jsp:useBean id="checkLogin" class="loginBean.LoginBean"/>
<head>
<title>?????</title>
<style type="text/css">
<!--
.style5 {color: #000000}
.style6 {font-family: "??-???????"}
.style7 {color: #8000FF; font-family: "??-???????"; }
-->
</style>
</head>
<body>
<form name="form1" method="post">
<p><span class="style7">??</span><span class="style5"><b><i><%=request.getParameter("username")%></i></span><span class="style7">???</span>
<span class="style6"><a href="denglu.jsp">??</a>
</span></p>
<h2><img src="020.gif" width="32" height="32"><span class="style6"><em><font size="3">?????</font></em></span><a href="www.shipin.com"><font size=3></font><font size=3>www.shipin.com</font></a></h2>
<div>
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|<br>
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|
<a href="">??</a>|
</div>
<div align=center>
<IMG height=100 src="021.jpg" width=777>
</div>
</form>
<%
checkLogin.init(request,out,response);
checkLogin.execute();
checkLogin.clean();
%>
</body>
</html>

#4
球球2006-08-07 09:08
因为当时没有对中文进行处理,结果出现乱码,而且页面已经是用乱码进行保存了,所以下次再开时依然是乱码.
不好意思,再改过来吧,并且进行下中文处理啦.
#5
神vLinux飘飘2006-08-07 12:08

恩,球球说得没错。
建议最好用统一的字符编码的平台。比如,统一用UTF8

1