`

ajax j调用产生空行处理

阅读更多
查询数据库输出时候多了很多空行
checkuser.jsp
<%@page   contentType= "text/html;charset=utf-8 "%> 
<%@   include   file= "include/common.jsp "%> 
<%@   include   file= "include/connectdb.jsp "%> 
<% 
String   username; 
username=request.getParameter( "username "); 
if(username== " "){   response.sendRedirect( "register.html ");} 
ResultSet   rs; 
String   sql; 
smt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 
sql= "SELECT   *     FROM   [user]   where   username   = ' "+username+ " ' "; 
rs   =   smt.executeQuery(sql); 
if   (!rs.next())   
        { 
    out.print( "true "); 
        }else{ 
out.print( "false "); 
} 
              con.close();   
                rs.close();   
                smt.close();   
con=null; 
rs=null; 
smt=null; 
%> 

运行该文件返回:


true
//true   的上面出现很多空行
//那个大大跟我说下原因哈~~~~因为我的ajax是从这个页采数据回来的     那么多的空行     处理起来很麻烦

------解决方案--------------------------------------------------------
<%@page contentType= "text/html;charset=utf-8 "%> 这句会引入一个回车换行
其他空行在你导入的几个头文件中,多找找。

另:空白字符在js中用replace(/^\s*/, " ")可以删除。
------解决方案--------------------------------------------------------
先执行一句out.clear();
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics