我用的是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 ");