<%@ page language="java" errorPage="../errorpage.jsp" contentType="text/html;charset=GB2312" %>
解决方案 »
- 我笔记本是AMD A4-3300M 用Myeclipse8.5总是很卡 而且我已经优化过了
- timer.schedule 不能配置按月执行 哪位ggjj帮帮忙
- Linux下,关于FileSystemXmlApplicationContext解析文件的问题
- 在myeclipse中开发struts需要引入的jar包是什么????
- 求通用权限管理模块代码
- Software caused connection abort: recv failed
- http下载文件名如何解决
- 疯狂求助(servlet中的汉字问题,高人请入)
- 帮忙找JS错误,代码如下:
- 我对JSP这个论坛真是失望!!!!!!!!!
- 请问:jboss和tomcat集成环境的http://localhost:8080/这个访问的默认文件应该在哪里设置?
- JSP中如何将字符串转为整型数啊?有没有类似C中字符串操作的函数啊?
request.getParameter("key").getBytes("ISO8859-1");
1:在jsp页面加入:
<%@ page contentType="text/html; charset=gb2312" %>
2:在servlet里面:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");//这是重要的
3:上面的如果在不行就用如下的方法在数据入库前进行调用:
public static String UnicodeToChinese(String s){
try{
if(s==null ¦ ¦s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
public static String ChineseToUnicode(String s){
try{
if(s==null ¦ ¦s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("gb2312"),"ISO8859_1");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}