请问怎么让jsp程序正确显示中文?

fanherong 2006-07-13 10:25:07
请问各位大虾怎样使jsp程序显示中文不出现乱码啊?是不是我的jdk或tomcat 版本问题啊?
...全文
113 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Javaxy 2006-07-14
  • 打赏
  • 举报
回复
在<% request.setCharacterEncoding("gb2312");

%>
3feetcat 2006-07-13
  • 打赏
  • 举报
回复
再加个过滤器

/**
*EncodingFilter.java
*@author adm
*@version 1.0
*2006-6-26日 13:51:59
*/
package com.shop.filter;

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

public class EncodingFilter implements Filter {

private String targetEncoding = "UTF-8";

public void init(FilterConfig filterConfig) throws ServletException {

}

public void doFilter(ServletRequest srequest, ServletResponse sresponse,
FilterChain chain) {
try {
HttpServletRequest request = (HttpServletRequest) srequest;
request.setCharacterEncoding(targetEncoding);
chain.doFilter(srequest, sresponse);
} catch (Exception e) {

}
}

public void destroy() {

}

}
limbo1982 2006-07-13
  • 打赏
  • 举报
回复
<%@ page contentType="text/html; charset=gb2312" language="java" %>
加在最上边
kingdoom 2006-07-13
  • 打赏
  • 举报
回复
<META http-equiv="Content-Type" content="text/html; charset=GB2312">

23,407

社区成员

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

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