从一个网页传送表单到别一个网页时的中文处理问题
2006-01-30 19:49
316 查看
第一种方法:
8.jps
<%@page contentType="text/html;charset=gb2312"%>
<html>
<body>
<form action="9.jsp">
<input type="text" name="d1" >
<input type="submit" value="asd">
</form>
</body>
</html>
9.jsp
<%@page contentType="text/html;charset=gb2312"%>
<%
String name;
name=new String(request.getParameter("d1").getBytes("ISO8859-1"),"GBK");
%>
<%=name%>
用到name=new String(request.getParameter("d1").getBytes("ISO8859-1"),"GBK");这个解决中文传送的问题。
第二种方法:
可以在本程序内加入以一下java代码函数,再调用就可以了;
<%!
public String getStr(String str1)
{
try
{
String temp_p=str1;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{
}
return "null";
}
%>
这里要用try ...catch捉异常
8.jps
<%@page contentType="text/html;charset=gb2312"%>
<html>
<body>
<form action="9.jsp">
<input type="text" name="d1" >
<input type="submit" value="asd">
</form>
</body>
</html>
9.jsp
<%@page contentType="text/html;charset=gb2312"%>
<%
String name;
name=new String(request.getParameter("d1").getBytes("ISO8859-1"),"GBK");
%>
<%=name%>
用到name=new String(request.getParameter("d1").getBytes("ISO8859-1"),"GBK");这个解决中文传送的问题。
第二种方法:
可以在本程序内加入以一下java代码函数,再调用就可以了;
<%!
public String getStr(String str1)
{
try
{
String temp_p=str1;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{
}
return "null";
}
%>
这里要用try ...catch捉异常
相关文章推荐
- 在struts框架中处理表单请求时的中文乱码问题
- 一个将html文件批量转换成jsp文件的程序(主要处理中文乱码问题)
- Pyhthon爬虫:关于中文网页的处理问题
- 乱码(1):Servlet编程中处理表单中的中文问题
- springMVC表单处理中文乱码问题
- 向网页传送中文参数乱码的问题
- ASP一个网页处理所有问题(添加,修改,删除,列表)框架
- 话题:jQuery 关于文件上传表单处理的一个非常怪异的问题
- 使用bs4获取网页时候,如何处理爬到页面内中文变成拉丁文问题
- jsp小问题之 表单传送中文信息
- 学习笔记:处理表单提交的中文乱码问题
- 通过Jquery中的选择器选择相同的className统一处理表单(可以同时处理多个表单在一个网页中)
- 如何处理网页中文乱码问题?
- [Java]一个TCP文本上传相关的异常处理和偶然引出的中文编码问题
- spring mvc的controller识别同一个form表单的多个submit按钮问题以及相关处理
- js对url网页地址中文乱码问题的处理方法
- Python问题记录:如何处理中文网页中的多余空格
- post表单处理中文乱码问题
- 把一个用sql server 2005内置加密方法加密数据的DB从一台电脑备份后,还原到另外一台电脑上,出现的问题的处理办法
- Struts之post提交表单出现中文乱码问题的解决方案