运行时显示乱码,试了n多方法还是不行,myeclipse里边jsp什么的设置的是utf-8。求大神解答
package servlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
-
Servlet implementation class firstServlet
*/
public class firstServlet extends HttpServlet {
private static final long serialVersionUID = 1L;/**
- @see HttpServlet#HttpServlet() */ public firstServlet() { super(); // TODO Auto-generated constructor stub }
/**
-
@see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");PrintWriter out = response.getWriter();
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html,charest=UTF-8");out.write("获取到的客户机信息如下:");
out.write("
");
out.write("请求的url地址:"+request.getRequestURL());
out.write("
");
out.write("请求的资源:"+request.getRequestURI());
out.write("
");
out.write("请求的URL地址中附带的参数:"+request.getQueryString());
out.write("
");
out.write("来访者的IP地址:"+request.getRemoteAddr());
out.write("
");
out.write("来访者的主机名:"+request.getRemoteHost());
out.write("
");
out.write("使用的端口号:"+request.getRemotePort());
out.write("
");
out.write("remoteUser"+request.getRemoteUser());
out.write("
");
out.write("请求使用的方法:"+request.getMethod());
out.write("
");
out.write("pathInfo:"+request.getPathInfo());
out.write("
");
out.write("localAddr:"+request.getLocalAddr());
out.write("
");
out.write("localName:"+request.getLocalName());
out.write("
");
out.close();
}
/** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}