这个jsp的返回值是什么?
<%@ page import= "javax.naming.Context " %>
<%@ page import= "javax.sql.DataSource "%>
<%@ page import= "javax.naming.* "%>
<%@ page import= "java.sql.* "%>
<jsp:useBean id= "db " scope= "application " class= "db.DB "/>
<%
response.setHeader( "Cache-Control ", "no-cache ");
response.setContentType( "text/html; charset=gbk ");
try{
String userid = request.getParameter( "userid ");
String pwd = request.getParameter( "pwd ");
ResultSet rs = db.executeQuery( "select priv from users where userid= ' "+userid+ " ' and password= ' "+pwd+ " ' ");
if(rs.next()){
out.print(true);
}else out.print(false);
db.close_all();
}catch(NamingException ne){ out.println(ne);}
%>
userid和password是前台通过ajax传过来的,同样在前台取得此jsp返回的responseText,用正确的帐号登录,传回的结果alert发现是很多空格,最后是true。
为什么不是true呢?(如果不用jsp,用servlet结果就是true。)
jsp和servlet在这点上有什么不同?
------解决方案--------------------out.print(true);
------解决方案--------------------out.print( "true ");//这样多半行