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是从这个页采数据回来的那么多的空行处理起来很麻烦
------解决方案--------------------------------------------------------
<%@pagecontentType="text/html;charset=utf-8"%>这句会引入一个回车换行
其他空行在你导入的几个头文件中,多找找。
另:空白字符在js中用replace(/^\s*/,"")可以删除。
------解决方案--------------------------------------------------------
先执行一句out.clear();
相关推荐
kentrl 2020-11-10
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo
ajaxyan 2020-11-09
zndy0 2020-11-03
学留痕 2020-09-20
Richardxx 2020-11-09
learningever 2020-09-19
chongxiaocheng 2020-08-16
ajaxhe 2020-08-16
lyqdanang 2020-08-16
curiousL 2020-08-03
TONIYH 2020-07-22
时光如瑾雨微凉 2020-07-19
83510998 2020-07-18
坚持着执着 2020-07-16
jiaguoquan00 2020-07-07
李永毅 2020-07-05
坚持着执着 2020-07-05