建议你到FAQ里面看看,那里有全面的乱码解决方案
在接受参数的页面加入如下代码,然后调用就行了
第一步:<%--转换来自Form中文输入用的函数,否则乱码--%>
<%!
public String getStr(String str) {
try {
String tempStr=str;
byte[] tempByte=tempStr.getBytes("ISO8859-1");
String temp=new String(tempByte);
return temp;
}catch (Exception e) {
return "error";
}
}
%>
第二步:<%=getStr(request.getParameter("你的变量"))%>就ok la
在接受参数的页面加入如下代码,然后调用就行了
第一步:<%--转换来自Form中文输入用的函数,否则乱码--%>
<%!
public String getStr(String str) {
try {
String tempStr=str;
byte[] tempByte=tempStr.getBytes("ISO8859-1");
String temp=new String(tempByte);
return temp;
}catch (Exception e) {
return "error";
}
}
%>
第二步:<%=getStr(request.getParameter("你的变量"))%>就ok la
解决方案 »
- 想自学JSP,必须具有HTML知识
- 怎么把word文件导入页面编辑器
- 请问以下程序有什么错吗?
- 请教:http://localhost:8080和http://192.168.0.5:8080有什么区别?
- 求救各位大虾(关于ajax+struts2登陆的问题)先谢过
- web.xml中配置错误界面出现错误
- tom2005(快乐着) ,NetSniffer(扑克)
- <a>标签如何用js判断后不跳转
- 运行Tomcat4.0.1时,出现错误提示:out of enviroment Using CLASSPATH,如何解决?谢谢!
- Struts2 API 为什么下载好 无法打开(没用)
- 求救!!!!(vb代码改为java代码)在线等待!!!
- 关于tomcat的问题
下面加上
<%request.setCharacterEncoding("gb2312");%>
呵呵
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{
}
return "null";
}