为什么汉字出乱码,错在哪呀 username 为输入
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
%@page import="java.util.*" %
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String username=request.getParameter("user_id");
String password=request.getParameter("password");
String e_mail= request.getParameter("e_mail");
%>
<%!
Hashtable hashtable = new Hashtable();
public synchronized void putName(String s) {
hashtable.put(s,s);
}
%>
<% if (username==null){
username="";
}
byte b[] =username.getBytes("utf-8");
username= new String (b);
if(!(hashtable.containsKey(username)))
{
putName(username);
out.print("<BR>"+"你已经注册成功"+username);
}
else
{
out.print("<br>"+"该用户名已经存在");
}
%>
</body>
</html>
----------------解决方案--------------------------------------------------------
<%@page contentType="text/html;charset=gb2312"%>
----------------解决方案--------------------------------------------------------
页面是utf-8格式的如何做呢
----------------解决方案--------------------------------------------------------
可以用过滤器来做:
而且要注意method设置为post。应该就能解决问题
----------------解决方案--------------------------------------------------------