<% Connection conn=JndiBean.getConnection();%>
<%!String sql = null;
ResultSet rs=null;
%>
<%
String username1=request.getParameter("username");
<%
sql = "select * from student [color=#FF0000]where StudentName like '"+username1+"'"[/color];
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
if(rs.next())
{
response.sendRedirect("index.jsp");
}
else out.println("用户未注册!");
conn.close();
%>
===================================================================
前面登陆页面不管我用户名输入什么都显示用户未注册
当我把红色的部分去掉,就能转到index.jsp,
当我把红色的改为where StudentName like '*****'" //***为数据库中存在的字符串
也能转到index.jsp
为什么我写like '[color=#FF0000]"+username1+"'"[/color]就不行呢
因为我测试的时候用户名用的纯数字,所有我想不应该是编码的问题。