日期:2014-05-20 浏览次数:20952 次
<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>
request.setCharacterEncoding("GBK");
------解决方案--------------------
首先要保证文件和编码要一致
静态文件要注意编码是ANSI还是Unicode还是utf-8
一般GBK类用ANSI、utf-8就用utf-8
jsp可以用注解<%@ page pageEncoding="GBK" %>规定输出的html文件编码格式
接收post参数要设置编码 request.setCharacterEncoding("GBK");