日期:2014-05-18  浏览次数:20652 次

50分谢谢解决 JSP页面乱码问题
<%@   include   file= "../conn.jsp "%>
<%
request.setCharacterEncoding( "GB2312 ");
String   username=request.getParameter( "username ");
String   password=request.getParameter( "password ");
String   sql= "select   *   from   scott.admin   where   username   =   ' "   +   username   +   " '   and   password   =   ' "   +   password   +   " ' ";  
ResultSet   rs=stmt.executeQuery(sql);  
      if(rs.next()){
session.putValue( "admin ",rs.getString( "username "));  
session.putValue( "flag ",rs.getString( "flag "));  
    response.sendRedirect( "manage.jsp ");  
      }else{
out.print( "   <LINK   rel= 'stylesheet '   type= 'text/css '   href= 'style.css '>   ");
out.print( "   <TITLE> 管理员身份验证 </TITLE>   ");
out.print( "   <BODY   bgcolor= '#39867B '>   ");
out.print( "   <BR> <BR> <BR>     ");      
out.print( "   <TABLE   align= 'center '   width= '300 '   cellpadding= '1 '   cellspacing= '1 '>   "   );          
out.print( "   <TR   bgcolor= '#CCCCCC '>     ");
out.print( "   <TD   colspan= '2 '   height= '15 '   bgcolor= '#E1F4EE '>   "   );        
out.print( "   <DIV   align= 'center '> 操作:确认身份失败! </DIV>   ");
out.print( "   </TD>   ");
out.print( "   </TR>   "     );  
out.print( "   <TR>   ");
out.print( "   <TD   colspan= '2 '   height= '23 '   bgcolor= '#E1F4EE '>   ");      
out.print( "   <DIV   align= 'center '> <BR> <BR> 非法登陆,您的操作已经被记录!!! <BR>   ");
out.print( "   <BR> <A   href= 'login.jsp '> 再次登录! </A> <BR>   ");
out.print( "   <BR>   ");
out.print( "   </DIV>   ");
out.print( "   </TD>   ");
out.print( "   </TR>   "   );
out.print( "   </TABLE>   "   );
      }
 
rs.close();
%>


conn.jsp
<%@page   contentType= "text/html;charset=GB2312 "%>
<%@   page   import= "java.sql.* "%>  

<%Class.forName( "com.mysql.jdbc.Driver ").newInstance();  

    //数据库用户名
    String   userName= "root ";
    //密码
    String   userPasswd= "123456 ";
    //数据库名
    String   dbName= "scott ";
    //联结字符串
    String   url= "jdbc:mysql://localhost/ "+dbName+ "?user= "+userName+ "&