加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajax j调用产生空行处理

发布时间:2020-12-16 00:52:07 所属栏目:百科 来源:网络整理
导读:查询数据库输出时候多了很多空行 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 ");
查询数据库输出时候多了很多空行
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();

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读