日期:2014-05-17 浏览次数:20780 次
function validate()
{
$.get("login",{loginName:encodeURI(encodeURI($("#loginName").val()))},function(data)
{
alert(data);
});
}
public class LoginAction
{
private String loginName;
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String execute() throws UnsupportedEncodingException
{
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("utf-8");
//URLEncoder.encode(loginName,"UTF-8");
URLDecoder.decode(new String(ServletActionContext.getRequest().getParameter("loginName").getBytes("ISO-8859-1"),"UTF-8"),"UTF-8");
//URLDecoder.decode(loginName, "utf-8");
PrintWriter out=null;
try {
out = response.getWriter();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if("夏".equals(loginName))
{
out.print("该名字不能被注册!");
}
else
{
out.print("该名字 可以被注册!");
}
return null;
}
}
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="utf-8"/>