刚刚拼接jQuery,发现结合Ajax很好用,代码量比起传统Ajax少了许多,下面是一个小例子:
Html页面代码:
后台JSP代码:
<%@ page contentType="text/html;charset=utf-8"%>
<%
request.setCharacterEncoding("utf-8");
String username = request.getParameter("username");
String password = request.getParameter("password");
String result = "
";
if(username!=null){
//页面采用get方式提交过来的话,这里需要编码转换
//username = new String(username.getBytes("ISO8859-1"),"utf-8");
result += ""+username+"";
}
if(password!=null){
//password = new String(password.getBytes("ISO8859-1"),"utf-8");
result += ""+password+"";
}
result += "";
response.setContentType("text/xml;charset=utf-8");
response.setHeader("Cache-control", "no-cache");
out.println(result);
%>
阅读(828) | 评论(0) | 转发(0) |