按照3楼的方法试了一下!!可以解决从类的方法中返回中文字符串的显示问题,但同时带来另一个问题,就是在HTML里面的中文字符显示变乱码了!!!见代码
<%@ page import="zqp.FirstClass" %>
<%@ page language="java" import="java.lang.*,java.util.*" %>
<%response.setContentType("text/html;charset=gb2312");
request.setCharacterEncoding("gb2312");%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
FirstClass m=new FirstClass();
String strName=m.GetName();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'test.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>
<%=strName%> <br>
<a>上海</a>
</body>
</html>