大家好,我是java的新手。我的datatable不工作(jsp),请帮帮我 [英] Hello guys, I'm new to java .my datatable is not working(jsp), please help me

查看:64
本文介绍了大家好,我是java的新手。我的datatable不工作(jsp),请帮帮我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

 <link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
 <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
 <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>User List</title>

 
  
   
</head>
<body>
<h3>User List:-</h3>
<%@page import ="java.sql.*" %>
<% 
String ademail=request.getParameter("aemail");
String adpass=request.getParameter("apass");

if(ademail.equals("admin")&& adpass.equals("admin")){
	session.setAttribute("user",ademail);  
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp",
        "root", "");
Statement st = con.createStatement();

ResultSet rs=st.executeQuery("select * from login");  


//out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3)+"<br>");  
//con.close();
    out.print("<div class='container-fluid'>");
    out.print("<div class='table-responsive col-md-12'  style='width:70%'>");
	out.print("<table border='1'  id='example' class='table table-hover nowrap'cellpadding='4' width='60%'>");  
	out.print("<thread><tr><th>Id</th><th>Name</th><th>Email</th></thread>"); 
	while(rs.next())  {
	 out.print("<tbody><tr><td>"+rs.getInt(1)+"</td> <td>"+rs.getString(2)+"</td> <td>"+rs.getString(3)+"</td></tr></tbody>");

	}
	out.print("</table></div>");
	out.print("</div>");
	
}else
{
	response.sendRedirect("admin.jsp");
}
%>
</body>
<script type="text/javascript">

$(document).ready(function() {
    $('#example').DataTable( {
    	 "pagingType": "full_numbers",
    	 "paging": true,
    	 "lengthChange": true,
         "searching": true,
         "ordering": true,
         "info": true,
         "autoWidth": true	
    	
    });
} );
	
</script>
</html>





我尝试过:



这是我的源代码,请告诉我cdn或其他任何问题。我是java的新手,请帮帮我



What I have tried:

This is my source code, please tell me if there is any problem with cdn or anything else. I'm new to java, please help me

推荐答案

(document).ready(function(){
(document).ready(function() {


(' #example')。DataTable({
pagingType:full_numbers,
paging:true,
lengthChange:true,
search:true,
ordering:true,
info:true,
autoWidth:true

});
});

< / script>
< / html>
('#example').DataTable( { "pagingType": "full_numbers", "paging": true, "lengthChange": true, "searching": true, "ordering": true, "info": true, "autoWidth": true }); } ); </script> </html>





我尝试过:



这是我的源代码,请告诉我cdn或其他任何问题。我是java的新手,请帮帮我



What I have tried:

This is my source code, please tell me if there is any problem with cdn or anything else. I'm new to java, please help me


请定义不工作。



这是你的数据表和页面这样其他人就无法访问它。



你必须得到有意义的错误信息才能知道出了什么问题。这包括检查参数(它们是否存在且有效),捕获异常(例如 SQLException (Java Platform SE 7) [ ^ ]由数据库访问函数抛出),并通过返回值检查指示错误的函数的返回值,而不是抛出异常。



顺便说一句:没有线程 HTML标签(应该可能 thead )。
Please define "not working".

It is your datatable and page so that nobody else can access it.

You have to get meaningful error message to know what went wrong. That includes checking the parameters (are they present and valid), catching exceptions (like SQLException (Java Platform SE 7 )[^] thrown by database access functions), and checking return values of functions which indicate errors through the return value rather than throwing exceptions.

By the way: There is no thread HTML tag (should be probably thead).


这篇关于大家好,我是java的新手。我的datatable不工作(jsp),请帮帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆