请问一下怎么是乱码呢 源文件<head>
<meta http-equiv="Content-Type" content="text/html;charset=gbk">
</head>
<body>
请输入三遍长度,输入数字用逗号分隔
<form action="triangle.jsp" method="post" name="form">
<input type="text" name="booy" value="示例:1,3,5">
<input type="submit" value="t提交" name="submit">
</form>
<%! String[] str = new String[3];
%><%
String s = request.getParameter("booy");
if(s!=null){
str = s.split(",");
for(int i=0;i<str.length;i++){
out.write(str[i]+";");
}
}
%>
</body>
</html>访问页面:提交后页面:原来没有<meta http-equiv="Content-Type" content="text/html;charset=gbk">
是乱码 加上这句还是乱
改成gb2312还是挺乱
<meta http-equiv="Content-Type" content="text/html;charset=gbk">
</head>
<body>
请输入三遍长度,输入数字用逗号分隔
<form action="triangle.jsp" method="post" name="form">
<input type="text" name="booy" value="示例:1,3,5">
<input type="submit" value="t提交" name="submit">
</form>
<%! String[] str = new String[3];
%><%
String s = request.getParameter("booy");
if(s!=null){
str = s.split(",");
for(int i=0;i<str.length;i++){
out.write(str[i]+";");
}
}
%>
</body>
</html>访问页面:提交后页面:原来没有<meta http-equiv="Content-Type" content="text/html;charset=gbk">
是乱码 加上这句还是乱
改成gb2312还是挺乱
解决方案 »
- 在 BUFFERREADER 的时候,能不能使 GC机制失效,不使用GC?
- 刚刚讯雷的一个笔试题
- java反射机制的问题
- jstl问题
- [100分]关于System.exit(0);中的exit方法的参数有多少值,分别表示什么意义?
- 一个程序在编译时通过了,但是运行时出现异常,请教怎么改正
- java网络问题!不是很难,帮着看看吧!
- 关于子类和父类构造函数之间的问题
- 一个关于java.lang.NoClassDefFoundError的问题?
- 向数据库插入日期问题
- 一个小小的计算题
- JOptionPane.showInputDialog 可不可一次输入多个值. 还是说只能输入一个值. 如果类库有这样的方法的话,自己就不用重写了.
<%@ page import="java.util.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gbk">
</head>
<body>
请输入三遍长度,输入数字用逗号分隔
<form action="triangle.jsp" method="post" name="form">
<input type="text" name="booy" value="示例:1,3,5">
<input type="submit" value="t提交" name="submit">
</form>
<%! String[] str = new String[3];
%><%
String s = request.getParameter("booy");
if(s!=null){
str = s.split(",");
for(int i=0;i<str.length;i++){
out.write(str[i]+";");
}
}
%>
</body>
</html>
静态文件要注意编码是ANSI还是Unicode还是utf-8
一般GBK类用ANSI、utf-8就用utf-8
jsp可以用注解<%@ page pageEncoding="GBK" %>规定输出的html文件编码格式
接收post参数要设置编码 request.setCharacterEncoding("GBK");