eclipse 编辑jsp中文问题

JeilyNE 2007-04-16 10:45:06
我用的是eclipse 3.2+tomcat5.5.17+myeclipse 5.1GA,在调试jsp的时候,如果jsp中包含中文的时候,在工程目录下的work文件夹里对应的临时servlet文件中就中文显示为乱码,不知为何。把myeclipse中jsp的编码格式设置成GB18030也不行,在网上搜了很久都没解决问题,请高手帮忙下,谢谢!

jsp代码:
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
试验
</body>
</html>

eclipse中自动编译的相对应servlet代码:out.write("璇曢獙\r\n");出现乱码

package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;

public final class te_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {

private static java.util.List _jspx_dependants;

public Object getDependants() {
return _jspx_dependants;
}

public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {

JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;


try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=GB18030");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;

out.write("\r\n");
out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=GB18030\">\r\n");
out.write("<title>Insert title here</title>\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write("璇曢獙\r\n");
out.write("</body>\r\n");
out.write("</html>");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
...全文
417 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangxiao_jiang 2007-04-16
  • 打赏
  • 举报
回复
把工程的编码设置成中文的。
GAVIN_JAVA616 2007-04-16
  • 打赏
  • 举报
回复
用GB2312
JeilyNE 2007-04-16
  • 打赏
  • 举报
回复
非常感谢楼上的几位兄弟,最后用UTF-8试下就可以了。感激涕零。。。但还不懂原理,再去查查。谢谢!
richboylf 2007-04-16
  • 打赏
  • 举报
回复
lz这个问题我也遇见过...用尽所有方法对不好使..最后只有遇见jsp中有中文的就在UE或者EditPlus中编辑....不要在eclipse中对jsp中中文进行修改.....和和..这也是没有办法的办法....
Ryo_Hazuki 2007-04-16
  • 打赏
  • 举报
回复
用UTF-8试试
yangxiao_jiang 2007-04-16
  • 打赏
  • 举报
回复
如果是从cvs上下的,就重新下一次,现更改编码,然后再打开文件。
yangxiao_jiang 2007-04-16
  • 打赏
  • 举报
回复
按照我说的,你需要把原来乱麻的地方都重新更新一下

你现在的原程序应该是在cvs上下载的吧?
JeilyNE 2007-04-16
  • 打赏
  • 举报
回复
高手出来说下为什么啊,被这个搞到头都大了,老是出错。。。。如果放在tomcat/webapps下则不会出现这种问题。eclipse下编码转换成乱码了。
JeilyNE 2007-04-16
  • 打赏
  • 举报
回复
yangxiao_jiang(哈哈),

我将project—properties-info—text file encoding 设置成GB2312,windows-properties-general-content type-text-jsp选项设置成GB2312,建立file test.jsp编译后其对应.java仍旧是乱码。

将windows-properties-myeclipse-jsp 选项设置成GB18030 建立 myeclipse jsp 文件test.jsp,对应的.java 仍旧是乱码

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧